A Little Knowledge

A Little Knowledge ...

or Differences between SOAP 1.1 and SOAP 1.2

Just been doing some work with a very knowledgable consultant from Tibco (Michael).  If he had been less knowledgable we could probably both have saved ourselves 30 minutes.  We got caught out by differences between SOAP 1.1 and SOAP 1.2.  My colleague Newton had built, using JDeveloper, a client to a web service defined by Michael based on some existing WSDL but then altered.  We were all somewhat surprised when the web service complained bitterly about the message being completely wrong.  A quick glance at the error logs and we were all suspicious of what appeared to be a missing SOAPAction in the HTML header, a wrong SOAP namespace and what appeared to be a mangled Content-Type HTTP header.
Headless chicken mode and we had all run round looking at what we had done and why it was wrong.  A little reflection then took place and we took stock of what we had.  The problem was that the client was using a SOAP 1.2 binding and the service was expecting a SOAP 1.1 binding.  If we hadn't played with the service after defining the WSDL all would have been well, but the world is full of if onlys.  Quick bit of matching and all was well.  Thought it might be informative to show the two messages side by side with the differences highlighted.
Note the difference in the HTTP headers and also in the SOAP namespace
  • HTTP header SOAPAction as an additional endpoint identifier goes away in SOAP 1.2, but may be included as an optional action property in the Content-Type.
  • HTTP header Content-Type is now application/soap+xml
  • Namespace of the SOAP envelope is now "http://www.w3.org/2003/05/soap-envelope"

SOAP 1.1
SOAP 1.2
HTTP Header
POST http://141.144.137.68:8988/TestBed-SOAP11-context-root/DriverServiceSoapHttpPort HTTP/1.1
Host: 141.144.137.68:8988
Proxy-Connection: Keep-Alive
Connection: TE
TE: trailers, deflate, gzip, compress
User-Agent: Oracle HTTPClient Version 10h
SOAPAction: "http://soapservice//canDrive"
Accept-Encoding: gzip, x-gzip, compress, x-compress
Content-type: text/xml; charset=UTF-8
Content-length: 450
POST http://141.144.137.68:8988/TestBed-SOAP11-context-root/DriverServiceSoap12HttpPort HTTP/1.1
Host: 141.144.137.68:8988
Proxy-Connection: Keep-Alive
Connection: TE
TE: trailers, deflate, gzip, compress
User-Agent: Oracle HTTPClient Version 10h
Accept-Encoding: gzip, x-gzip, compress, x-compress
Content-type: application/soap+xml; charset=UTF-8;action="http://soapservice//canDrive"
Content-length: 452
HTTP Body
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
                       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                       xmlns:ns0="http://soapservice/types/">
 <env:Body>
  <ns0:canDriveElement>
   <ns0:country>UK</ns0:country>
   <ns0:person>
    <ns0:last>Doe</ns0:last>
    <ns0:age>17</ns0:age>
    <ns0:first>John</ns0:first>
   </ns0:person>
  </ns0:canDriveElement>
 </env:Body>
</env:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
                       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                       xmlns:ns0="http://soapservice/types/">
 <env:Body>
  <ns0:canDriveElement>
   <ns0:country>France</ns0:country>
   <ns0:person>
    <ns0:last>Doe</ns0:last>
    <ns0:age>17</ns0:age>
    <ns0:first>John</ns0:first>
   </ns0:person>
  </ns0:canDriveElement>
 </env:Body>
</env:Envelope>

It is probably worth noting that it is possible to have both SOAP 1.1 and SOAP 1.2 bindings active concurrently in a server and choose which one to use from within the client application.  A word of caution, when I did this with JDeveloper it set the port name incorrectly for the SOAP 1.2 client when I generated it at the same time as the SOAP 1.1 bindings.  I manually fixed this, and it seems to work fine when a single binding is generated - just something to watch out for.

Comments:

Post a Comment:
Comments are closed for this entry.
About

Musings on Fusion Middleware and SOA Picture of Antony Antony works with customers across the US and Canada in implementing SOA and other Fusion Middleware solutions. Antony is the co-author of the SOA Suite 11g Developers Cookbook, the SOA Suite 11g Developers Guide and the SOA Suite Developers Guide.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today