85

Is it possible to see if a web service uses SOAP 1.1 or 1.2, based on the information in the WSDL?

mjn
  • 36,362
  • 28
  • 176
  • 378

5 Answers5

86

SOAP 1.1 uses namespace http://schemas.xmlsoap.org/wsdl/soap/

SOAP 1.2 uses namespace http://schemas.xmlsoap.org/wsdl/soap12/

The wsdl is able to define operations under soap 1.1 and soap 1.2 at the same time in the same wsdl. Thats useful if you need to evolve your wsdl to support new functionality that requires soap 1.2 (eg. MTOM), in this case you dont need to create a new service but just evolve the original one.

jmhostalet
  • 4,399
  • 4
  • 38
  • 47
48

In WSDL, if you look at the Binding section, you will clearly see that soap binding is explicitly mentioned if the service uses soap 1.2. refer the below sample.

<binding name="EmployeeServiceImplPortBinding" type="tns:EmployeeServiceImpl">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="findEmployeeById">
    <soap12:operation soapAction=""/>
    <input><soap12:body use="literal"/></input>
    <output><soap12:body use="literal"/></output>
</operation><operation name="create">
    <soap12:operation soapAction=""/>
    <input><soap12:body use="literal"/></input>
    <output><soap12:body use="literal"/></output>
</operation>
</binding>

if the web service use soap 1.1, it will not explicitly define any soap version in the WSDL file under binding section. refer the below sample.

<binding name="EmployeeServiceImplPortBinding" type="tns:EmployeeServiceImpl">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="findEmployeeById">
    <soap:operation soapAction=""/>
    <input><soap:body use="literal" namespace="http://jaxb.ws.jax.samples.chathurangaonline.com/"/></input>
    <output><soap:body use="literal" namespace="http://jaxb.ws.jax.samples.chathurangaonline.com/"/></output>
</operation><operation name="create">
    <soap:operation soapAction=""/>
    <input><soap:body use="literal" namespace="http://jaxb.ws.jax.samples.chathurangaonline.com/"/></input>
    <output><soap:body use="literal" namespace="http://jaxb.ws.jax.samples.chathurangaonline.com/"/></output>
</operation>
</binding>

How to determine the SOAP version of the SOAP message?

but remember that this is not much recommended way to determine the soap version that your web services uses. the version of the soap message can be determined using one of following ways.

1. checking the namespace of the soap message

SOAP 1.1  namespace : http://schemas.xmlsoap.org/soap/envelope

SOAP 1.2 namespace  : http://www.w3.org/2003/05/soap-envelope

2. checking the transport binding information (http header information) of the soap message

SOAP 1.1 : user text/xml for the Context-Type

   POST /MyService HTTP/1.1
   Content-Type: text/xml; charset="utf-8"
   Content-Length: xxx
   SOAPAction: "urn:uuid:myaction"

SOAP 1.2 : user application/soap+xml for the Context-Type

   POST /MyService HTTP/1.1
   Content-Type: application/soap+xml; charset="utf-8"
   Content-Length: xxx
   SOAPAction: "urn:uuid:myaction"

3. using SOAP fault information

The structure of a SOAP fault message between the two versions are different.

Chathuranga Tennakoon
  • 2,059
  • 1
  • 18
  • 20
  • 19
    The first part of your answer could use some additional information - the "soap12" is the namespace prefix, not the namespace itself. You need to check what the "soap12" prefix resolves to, and which version of soap that specifies. Someone could use soap12 as the prefix but point to the soap11 namespace URI. – csadler May 12 '16 at 14:37
  • Thank you this was so useful. – vikingsteve Jan 10 '19 at 12:37
  • 2
    The comment by @csadler is extremely important but even there, correct values of namespaces are not provided. Here you are. The `soap` prefix that refers to 1.1 is `http://schemas.xmlsoap.org/wsdl/soap/`. The `soap12` prefix that refers to 1.2 is `http://schemas.xmlsoap.org/wsdl/soap12/`. Whatever the prefix name is (could be even `foo` or `bar`), just take a look to what namespace it resolves. – Wiktor Zychla Mar 04 '20 at 10:52
15

I have found this page

http://schemas.xmlsoap.org/wsdl/soap12/soap12WSDL.htm

which says that Soap 1.2 uses the new namespace http://schemas.xmlsoap.org/wsdl/soap12/

It is in the 'WSDL 1.1 Binding extension for SOAP 1.1'.

mjn
  • 36,362
  • 28
  • 176
  • 378
6

Yes you can usually see what SOAP version is supported based on the WSDL.

Take a look at Demo web service WSDL. It has a reference to the soap12 namespace indicating it supports SOAP 1.2. If that was absent then you'd probably be safe assuming the service only supported SOAP 1.1.

sipsorcery
  • 30,273
  • 24
  • 104
  • 155
  • The soap12 namespace reference is a good indicator. But if it is missing, it still can be a SOAP 1.2 web service - the example WSDL at http://en.wikipedia.org/wiki/Web_Services_Description_Language als does not have this reference, but maybe it contains something else which is typical for SOAP 1.2? – mjn Apr 10 '09 at 06:41
2

Found transport-attribute in binding-element which tells us that this is the WSDL 1.1 binding for the SOAP 1.1 HTTP binding.

ex.

<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
LilleElefant
  • 422
  • 1
  • 5
  • 14