2

匿名認証で WCF サービスを作成しようとしています。現在のドメインにない宛先サーバーにサービスをデプロイすると、サービスを呼び出そうとすると次のエラーが表示されます。

コンテンツ タイプ application/soap+xml; charset=utf-8 は、サービスhttp://myserver.com/page.svcでサポートされていませんでした。クライアントとサービスのバインディングが一致していない可能性があります。

現在のところ、サービスの web.config ファイルに次のセクションがあります。

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
    </modules>
  </system.webServer>

さまざまなバインディング (wsHttpBinding および basicHttpBinding) を試していますが、上記のエラー (basicHttpBinding を使用) または「アクセスが拒否されました」というメッセージ (wsHttpBinding を使用) を受け取ります。これは、wsHttpBinding を使用するときに使用しようとした web.config セクションです。

 <system.serviceModel>
  <services>
   <service behaviorConfiguration="AMP.MainBehavior" name="AMP.Main">
    <endpoint address="" binding="wsHttpBinding" contract="AMP.IMain">
      <identity>
        <dns value="myservice.com"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
   </service>
  </services>
  <behaviors>
    <serviceBehaviors>
    <behavior name="AMP.MainBehavior">
     <serviceMetadata httpGetEnabled="true"/>
     <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
   </serviceBehaviors>
  </behaviors>
 </system.serviceModel>

このサービスは、.NET 4.0 フレームワークで作成されています。匿名にする必要がありますが、何が欠けているのかわかりません。私はWCFを初めて使用するので、まだすべてのアヒルを続けているわけではありません。

ありがとうございました、

4

1 に答える 1

3

このエラーは、サポートされていないコンテンツ タイプで HTTP 要求を送信していることを示しています。上記のコンテンツ タイプは SOAP 1.2 で使用されますが、BasicHttpBinding は異なるコンテンツ タイプ (text/xml; charset=utf-8) の SOAP 1.1 を使用します。そのため、サービスとクライアントの構成の間に不一致がある可能性があります。

2 番目の例では、問題はデフォルトの WsHttpBinidng 構成です。WsHttpBinding はデフォルトで、メッセージ セキュリティと Windows 認証 => 例外で保護されています。これは、マシンが異なるドメインにあり、Windows 認証が機能しないためです。独自の WsHttpBinding 構成を定義する必要があります。これを試してください(クライアントで同じバインディング構成を使用する必要があります):

<system.serviceModel>
  <bindings>
    <wsHttpBinding>
      <binding name="Unsecured">
        <security mode="None" />   
      </binding>
    </wsHttpBinding>
  </bindings>
  <services>
    <service ...>
      <endpoint address="..." contract="..." 
         binding="wsHttpBinding" bindingConfiguration="Unsecured" />
      ...
    </service>
  </services>
</system.serviceModel>
于 2010-09-29T11:51:51.593 に答える