ASMX 2.0 – SOAP 1.2 Support

The new ASMX runtime in .NET 2.0 will support SOAP 1.2. How
useful this turns out to be remains to be seen since almost
everyone is using SOAP 1.1 at the moment. By default, web services
will have both SOAP 1.1 and SOAP 1.2 bindings exposed on the server
side and will accept messages for either. The following excerpt
from the WSDL file of a simple service shows the two bindings:

<wsdl:binding name="SimpleServiceSoap" type="tns:SimpleServiceSoap">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
  <wsdl:operation name="Hello">
    <soap:operation soapAction="urn:simple/Hello" style="document" /> 
    <wsdl:input>
      <soap:body use="literal" /> 
    </wsdl:input>
    <wsdl:output>
      <soap:body use="literal" /> 
    </wsdl:output>
  </wsdl:operation>
</wsdl:binding>
<wsdl:binding name="SimpleServiceSoap12" type="tns:SimpleServiceSoap">
  <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
  <wsdl:operation name="Hello">
    <soap12:operation soapAction="urn:simple/Hello" style="document" /> 
    <wsdl:input>
      <soap12:body use="literal" /> 
    </wsdl:input>
    <wsdl:output>
      <soap12:body use="literal" /> 
    </wsdl:output>
  </wsdl:operation>
</wsdl:binding>

You can control whether you want these bindings enabled through
the web.config file. The following configuration file removes the
SOAP 1.2 binding:

<configuration>
  <system.web>
    <webServices>
      <protocols>
        <remove name="HttpSoap1.2"/>
      </protocols>
    </webServices>
  </system.web>
</configuration>

Replace “HttpSoap1.2” with “HttpSoap” to remove the SOAP 1.1
binding.

On the client side, WSDL.EXE generates SOAP 1.1 proxy code by
default. There is a /protocol command line option to WSDL.EXE that
allows you to specify which version to use. /protocol:SOAP
generates a SOAP 1.1 client and /protocol:SOAP12 generates a SOAP
1.2 client:

C:>wsdl /o:simpleproxy.cs /protocol:SOAP http://localhost/simple.asmx
Microsoft (R) Web Services Description Language Utility
[Microsoft(R) .NET Framework, Version 2.0.40607.85]
Copyright (C) Microsoft Corporation. All rights reserved.

Writing file 'simpleproxy.cs'.

C:>wsdl /o:simpleproxy12.cs /protocol:SOAP12 http://localhost/simple.asmx
Microsoft (R) Web Services Description Language Utility
[Microsoft(R) .NET Framework, Version 2.0.40607.85]
Copyright (C) Microsoft Corporation. All rights reserved.

Writing file 'simpleproxy12.cs'.

C:>

The System.Web.Services.Protocols.SoapHttpClientProtocol class
that is used as the base class of the generated client proxies has
a new property SoapVersion. This is set to
SoapProtocolVersion.Soap12 to indicate that SOAP 1.2 should be
used. The correct binding name is also chosen from the WSDL
(SimpleServiceSoap vs. SimpleServiceSoap12 from the WSDL example
above).

Note: this post was written against .NET 2.0 Beta 1. Expect some
subtle changes to the names of things in Beta 2 onwards.