WCF - 服务引用失败LogIn因为soap版本

时间:2016-02-11 14:58:22

标签: c# web-services wcf soap

当我尝试登录WCF时,收到错误消息:

An exception of type 'System.ServiceModel.CommunicationException' occurred in mscorlib.dll but was not handled in user code

Additional information: The envelope version of the incoming message (Soap12 (http://www.w3.org/2003/05/soap-envelope))
does not match that of the encoder (Soap11 (http://schemas.xmlsoap.org/soap/envelope/)).
Make sure the binding is configured with the same version as the expected messages.

我试图按照推荐的方式解决它 as answer to similar question

替换:

<basicHttpBinding>
    <binding name="LoginServiceSoap" />
</basicHttpBinding>

使用:

<basicHttpBinding>
   <binding name="LoginServiceSoap"
         envelopeVersion="Soap12" />
</basicHttpBinding> 

但是我收到了一个错误:

the "envelopeVersion"attribute is not allowed

感谢。

1 个答案:

答案 0 :(得分:0)

basicHttpBinding是SOAP 1.1。 documentation表示对envelopeVersion唯一有效值的绑定是“Soap11”。

wsHttpBinding是SOAP 1.2。尝试使用它而不是basicHttpBinding

<wsHttpBinding>
  <binding name="LoginServiceSoap" />
</wsHttpBinding>