コンテンツタイプ application/soap+xml; charset=utf-8 はサービスでサポートされていません 質問する

コンテンツタイプ application/soap+xml; charset=utf-8 はサービスでサポートされていません 質問する

WCF サービスを WCFTestClient に追加しようとしたときに、以下のエラーが発生します。Web 上でいくつかの解決策を試しましたが、うまくいきませんでした。

誰かこの問題を解決してくれませんか? サービス用の設定ファイルも提供しています:

コンテンツ タイプ application/soap+xml; charset=utf-8 はサービスでサポートされていません。クライアントとサービスのバインディングが一致していない可能性があります。リモート サーバーがエラーを返しました: (415) コンテンツ タイプ 'application/soap+xml; charset=utf-8' が予期されたタイプ 'text/xml; charset=utf-8' ではないため、メッセージを処理できません。

コード:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file 
  must be added to the host's app.config file. System.Configuration does not 
  support config files for libraries. -->
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttp" allowCookies="true"
                 maxReceivedMessageSize="20000000"
                 maxBufferSize="20000000"
                 maxBufferPoolSize="20000000">
          <readerQuotas maxDepth="32"
               maxArrayLength="200000000"
               maxStringContentLength="200000000"/>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
     <service name="WCFTradeLibrary.TradeService">
        <endpoint address="" binding="basicHttpBinding"
            bindingConfiguration="basicHttp"
            contract="WCFTradeLibrary.ITradeService">          
         </endpoint>
     </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint 
          above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faul`enter code here`ts for 
          debugging purposes,  
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception info`enter code here`rmation -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

ベストアンサー1

命名問題が発生しました。サービス名は実装の名前と正確に一致する必要があります。一致しない場合は、デフォルトでコンテンツ タイプが使用されbasicHttpBindingますtext/xml

クラス名は、SVC マークアップと CS ファイルの 2 か所にあります。

エンドポイント コントラクトも確認してください。ここでも、インターフェイスの正確な名前のみが必要です。それ以上のことはありません。アセンブリ名を追加しましたが、そこには存在できません。

<service name="MyNamespace.MyService">
    <endpoint address="" binding="wsHttpBinding" contract="MyNamespace.IMyService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>

おすすめ記事