我在嘗試向WCFTestClient添加WCF服務時遇到了錯誤。我在網上瀏覽了一些解決方案,但是我無法完成它的工作。內容類型application/soap + xml; charset = utf-8不被服務支持
有人可以幫我解決這些問題嗎? 我也提供我的配置文件服務:
Content Type application/soap+xml; charset=utf-8 was not supported by service The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type '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>
可能的重複:http://stackoverflow.com/questions/8087515/wcf-service-using-basichttpbinding-is-still-sending-content-type-text-xml?rq=1 – 2013-07-01 10:01:07
這是一個老問題,但它顯示爲Google的第一個答案。我只想指出,錯誤信息可能會引起誤解。根本的錯誤可能是完全無關的......這發生在我身上。 – sean717 2016-02-03 20:46:01
當我向類中添加構造函數時,出現此錯誤。 – MC9000 2016-05-16 02:52:30