12

I want to set message version for WSHttpBinding to EnvelopeVersion.Soap11. I don't know how to do that. Can any one help me. Here is my binding code

var binding = new WSHttpBinding()
        {
            UseDefaultWebProxy = true,
            Security =
            {
                Mode = SecurityMode.Transport,
                Transport =
                {
                    ClientCredentialType = HttpClientCredentialType.Basic
                },
            },
        };

EDIT: here is the code to do that

TransportBindingElement transportElement = null;

        transportElement = new HttpsTransportBindingElement();

        ((HttpsTransportBindingElement)transportElement).AuthenticationScheme = AuthenticationSchemes.Basic;
        ((HttpsTransportBindingElement) transportElement).KeepAliveEnabled = false;

        var messegeElement = new TextMessageEncodingBindingElement
        {
            MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap11, AddressingVersion.None),
            ReaderQuotas =
                    {
                        MaxArrayLength = 200000,
                        MaxBytesPerRead = 200000,
                        MaxDepth = 200000,
                        MaxNameTableCharCount = 200000,
                        MaxStringContentLength = 200000
                    }
        };

        var binding = new CustomBinding(messegeElement, transportElement);
        return binding;
Amzath
  • 3,159
  • 10
  • 31
  • 43

1 Answers1

8

In order to achieve this, you need to define a custom binding - in config or in code.

In config, you'd do it something like this:

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

and then, in your service or client config, use something like this:

   <services>
      <service name="test">
         <endpoint name="TestEP"
             address=""
             binding="customBinding"
             bindingConfiguration="Soap11"
             contract="IService" />
      </service>
   </services>
</system.serviceModel>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • @amz: you should **update** your original question with this solution; there you can properly format and present it - here in comments, it's a messy affair.... – marc_s Nov 12 '10 at 22:16