SOAP1.1 vs SOAP1.2

webservice owner แต่ละแห่งใช้มาตรฐานของ SOAP ต่างกัน เราจึงควรเลือกใช้ให้ถูกต้อง

Using SOAP Namespace

Every XML message contains namespaces to properly qualify the entities within it. In SOAP 1.1 and SOAP 1.2 specifications, each had defined its own unique namespaces to define the entities belonging to those specifications.

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

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

This is the easiest and sometimes the only method some people use. You can look at the SOAP namespace of a SOAP message and easily determine its version.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
.........
</soapenv:Header>
<soapenv:Body>
....
</soapenv:Body>
</soapenv:Envelope>

Using Transport Binding Information

Each SOAP specification defines transport binding rules to be used when using different transports.
These rules will define the semantics of the message, when it is transported through that transport medium.
For example, HTTP binding rules will define which HTTP header it should have and its contents or restrictions,
if any. Some of the rules defined in these binding specifications will help you to differentiate
among the different SOAP versions. Since HTTP is used more often, we will only discuss HTTP binding here.
If you need information on other transports, please refer to the respective transport binding specifications.
As the name depicts, the 'Content-Type' HTTP header will define the contents of the HTTP message.
SOAP 1.1 HTTP binding mandates the presence of a defined content-type.
Also, the specification mandates the presence of a new HTTP header, called the 'SOAPAction' header.
This is normally used to indicate the intent of the SOAP message.
Practically this header value gives a hint about the operation to be invoked with the given SOAP message.
POST /MyService HTTP/1.1
Content-Type: text/xml; charset="utf-8"
Content-Length: xxx
SOAPAction: "urn:uuid:myaction"
<SOAP-ENV:Envelope...

A typical HTTP header of a SOAP 1.1 message

The content type of the message can be text/xml, but there can be other content types in the message. There should be a SOAPAction header in any SOAP 1.1 message. This SOAPAction header can be empty, but it has to be there.

With SOAP 1.2 the identification becomes tricky. As with the SOAP 1.1 specification, the content type can be application/soap+xml, but users can define their own appropriate content types depending on the content. Also the specification does not define any SOAPAction header to be included within HTTP headers. You may include the SOAPAction information into the Content-type header itself. This is not mandatory.

POST /MyService HTTP/1.1
Host: myexample.org
Content-Type: application/soap+xml; charset="utf-8"
Content-Length: xxx
<SOAP-ENV:Envelope...
Reference http://wso2.com/library/articles/differentiating-between-soap-versions-looking-soap-message/

Related posts:

This entry was posted in knowledge. Bookmark the permalink.