[英]Cannot process the message because of the exception 'application/soap+xml; was not the expected type 'application/soap+msbin1'
[英]Cannot process the message because the content type 'application/soap+msbin1' was not the expected type 'text/xml
我有一個Silverlight應用程序,可以在我的開發環境(Win 7)中成功調用WCF。 當我檢查Fiddler中返回的內容類型時,它顯示如下。
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 18849
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 01 Sep 2014 14:59:01 GMT
但是,一旦在QA服務器(IIS 6.0)中部署了應用程序,對WCF服務的調用就會失敗,並出現以下錯誤(同樣來自Fiddler)
HTTP / 1.1 415無法處理消息,因為內容類型“ application / soap + msbin1”不是預期的類型“ text / xml”; charset = utf-8'。
我想知道為什么它從text / xml改變了; 部署時,將dev中的charset = utf-8升級到application / soap + msbin1。
我已閱讀了有關不匹配綁定的原因,並試圖驗證客戶端和服務器之間的所有內容是否匹配,但是我無法獲取匹配的內容類型。
以下是我的配置摘要。
Web配置
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DataSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport" />
</binding>
<binding name="DataSoap1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="MyApp.Web.GetData" behaviorConfiguration="MyApp.Web.GetData" >
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="DataSoap" contract="MyApp.Web.GetData" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyApp.Web.GetData">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
下面是ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DataSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport" />
</binding>
<binding name="DataSoap1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport" />
</binding>
</basicHttpBinding>
<customBinding>
<binding name="CustomBinding_GetData">
<binaryMessageEncoding />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="//localhost/MyApp/Webservice/Data.asmx"
binding="basicHttpBinding" bindingConfiguration="DataSoap"
contract="ServiceReference1.DataSoap" name="DataSoap" />
<endpoint address="//localhost/MyApp/Webservice/GetData.svc"
binding="basicHttpBinding" bindingConfiguration="DataSoap1"
contract="GetData.GetData" name="CustomBinding_GetData" />
</client>
</system.serviceModel>
我的工作方式與安全模式=“ None”相似,現在可以為我工作。 你可以試試。 但是,如果您必須使用安全性模式,我想您應該嘗試其他類型的綁定,例如WSHttpBinding而不是basicHttpBinding
PD 5個月后才回答^^
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.