Asp.net 更新服务参考时出现间歇性错误“;无法处理该邮件,因为内容类型…“;

Asp.net 更新服务参考时出现间歇性错误“;无法处理该邮件,因为内容类型…“;,asp.net,wcf,service-reference,Asp.net,Wcf,Service Reference,更新WCF service Relence时,我间歇性地收到错误“无法处理消息,因为内容类型‘application/soap+xml;charset=utf-8’不是预期的类型‘text/xml;charset=utf-8’”大约有50%的时间会发生这种情况。我会更新服务参考。它失败了。我再次更新(没有更改),它可以工作 编辑: 服务web.config: <?xml version="1.0" encoding="utf-8"?> <configuration>

更新WCF service Relence时,我间歇性地收到错误“无法处理消息,因为内容类型‘application/soap+xml;charset=utf-8’不是预期的类型‘text/xml;charset=utf-8’”大约有50%的时间会发生这种情况。我会更新服务参考。它失败了。我再次更新(没有更改),它可以工作

编辑: 服务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>
<?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>

客户端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>
<?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>

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

可能与此有关: