更新服务引用时的间歇性错误"因内容类型而无法处理消息..."

时间:2015-02-24 19:17:46

标签: asp.net wcf service-reference

当更新WCF服务时,我间歇地得到错误“无法处理消息,因为内容类型'application / soap + xml; charset = utf-8'不是预期的类型' text / xml; charset = utf-8'“。 它发生在大约50%的时间。我更新服务引用。它失败。我再次更新(没有变化)并且有效。

编辑: service web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="2147483647"></binding>
      </basicHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
  </system.serviceModel>
</configuration>

客户端web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation batch="false" debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" maxRequestLength="200000" executionTimeout="3600" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IMyAppData" closeTimeout="Infinite"
          openTimeout="Infinite" receiveTimeout="Infinite" sendTimeout="Infinite"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost/MyApp.Data.Host/MyApp.Data.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyAppData"
        contract="DataClient.IMyAppData" name="BasicHttpBinding_IMyAppData" />
    </client>
    <services>
    </services>
  </system.serviceModel>
</configuration>

1 个答案:

答案 0 :(得分:0)

我听起来你在服务和客户端绑定配置之间存在绑定不匹配。如果您需要正确的答案,请向我们提供服务和客户端的.config文件。您如何更新服务参考?

也许相关: Content Type text/xml; charset=utf-8 was not supported by service