我有一个Silverlight应用程序,它在我的开发环境中成功地调用了一个WCF (Win 7)。当我检查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’。
我想知道为什么部署时会从dev中的text/xml;charset=utf-8更改为application/soap+msbin1 1。
我已经阅读了不匹配的绑定是原因,并试图验证每件事之间的客户端和服务器之间的匹配,但我是,我不能得到的内容类型匹配。
下面是我的配置的片段。
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>
发布于 2015-01-28 00:40:59
我的工作方式与我所做的security mode=“无”类似,现在为我工作。你可以试试。但是如果您必须使用安全模式,我认为您应该尝试另一种类型的绑定,比如WSHttpBinding,而不是basicHttpBinding
下午5个月延迟答复^^
https://stackoverflow.com/questions/25608881
复制相似问题