我有一个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;字符集= UTF-8' 。
我想知道为什么它会从text / xml改变;在部署时,devs中的charset = utf-8到application / soap + msbin1。
我已经阅读了关于不匹配的绑定的原因,并尝试验证客户端和服务器之间的所有内容是否匹配,但我无法获得内容类型匹配。
以下是我配置的摘要。
的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>
答案 0 :(得分:0)
我的工作类似于我所做的安全模式=“无”,现在适用于我。 你可以尝试一下。但是如果你必须使用安全模式,我认为你应该尝试其他类型的绑定,如WSHttpBinding而不是basicHttpBinding
Pd积。 5个月延迟回答^^