如何在app.config中设置MessageVersion绑定?

时间:2018-06-14 14:36:00

标签: c# .net console-application

我的app.config文件中有一个绑定,如下所示:

 <bindings>    
  <basicHttpBinding>        
    <binding name="WebapiBindingWithCred" maxReceivedMessageSize="2147483647" messageEncoding="Text">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
        maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="UserName"/>          
      </security>        
    </binding>   
  </basicHttpBinding>
</bindings>

当我使用它时,我会收到`无法识别的消息版本&#39;错误作为回应。我已经阅读了我应该将我的MessageVersion设置为Soap11,但我无法在任何地方找到标签。我该怎么办?

1 个答案:

答案 0 :(得分:1)

您的绑定中需要以下标记:

<textMessageEncoding messageVersion="Soap11" />

但是,您需要使用自定义绑定,而不是basicHttpBinding:

 <customBinding>  
    <binding name="HttpBinding" >  
        <textMessageEncoding   
            messageVersion="Soap11"/>  
        <httpTransport />  
    </binding>  
 </customBinding>