Wcf 无法处理邮件,因为内容类型为';应用程序/soap+;msbin1';不是预期的类型';文本/xml
我有一个Silverlight应用程序,它在我的开发环境(Win7)中成功地调用了WCF。当我检查Fiddler中返回的内容类型时,它显示如下Wcf 无法处理邮件,因为内容类型为';应用程序/soap+;msbin1';不是预期的类型';文本/xml,wcf,soap,silverlight-5.0,basichttpbinding,Wcf,Soap,Silverlight 5.0,Basichttpbinding,我有一个Silverlight应用程序,它在我的开发环境(Win7)中成功地调用了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 Dat
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”;字符集=utf-8'
我想知道为什么它会从text/xml改变;部署时,dev to application/soap+msbin1中的charset=utf-8
我已经读过不匹配的绑定是原因,并试图验证客户端和服务器之间的所有内容是否匹配,但我很抱歉,我无法获得匹配的内容类型
下面是我的配置片段
Web.Config
<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>
我现在的工作方式与我以前设置的安全模式=“无”类似,现在对我有效。 你可以试试。但是如果您必须使用安全模式,我认为您应该尝试其他类型的绑定,比如WSHttpBinding,而不是basicHttpBinding p.D.延迟5个月答复^^