BasicHttpBinding和MessageVersion.None

时间:2010-05-17 08:42:06

标签: c# wcf wcf-binding

如何配置XML Web服务客户端以将MessageVersion.Soap11WSAddressing10用于标头命名空间。目前它使用MessageVersion.None命名空间,我无法更改它。

1 个答案:

答案 0 :(得分:2)

您需要使用自定义WCF绑定来执行此操作:

  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="Soap11Addr10">
          <textMessageEncoding messageVersion="Soap11WSAddressing10" />
          <httpTransport/>
        </binding>
      </customBinding>
    </bindings>

然后在服务端点中引用自定义绑定(按名称):

    <services>
      <service name="YourAssembly.YourService">
        <endpoint name="test"
                  address=""
                  binding="customBinding"
                  bindingConfiguration="Soap11Addr10"
                  contract="YourAssembly.IYourService" />
      </service>
    </services>
  </system.serviceModel>

如果您想从客户端使用此功能,您还需要将自定义绑定配置复制到客户端的app.configweb.config并在那里引用它(当然使用Add Service Reference在Visual Studio中将为您执行此操作。)