Monthly Archives: August 2023

SOAP Request Operation and Axis2

There are two versions of SOAP requests: SOAP 1.1 and SOAP 1.2

Example of SOAP1.1

POST https://example.com/myservice HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction:"urn:HeartBeat"
User-Agent: xxx
Host: example.com
Content-Length: xxx

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <ns1:HeartBeat xmlns:ns1="http://example.com">
      <ns1:login>test</ns1:login>
      <ns1:pass>****</ns1:pass>
    </ns1:HeartBeat>
  </soapenv:Body>
</soapenv:Envelope>

Example of SOAP1.2

POST https://example.com/myservice HTTP/1.1
Content-Type: application/soap+xml; charset=UTF-8; action="urn:HeartBeat"
User-Agent: xxx
Host: example.com
Content-Length: xxx

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Body>
    <ns1:HeartBeat xmlns:ns1="http://example.com">
      <ns1:login>test</ns1:login>
      <ns1:pass>****</ns1:pass>
    </ns1:HeartBeat>
  </soapenv:Body>
</soapenv:Envelope>

Their differences are:

  • Content-Type (HTTP header)
    • Content-Type: text/xml; charset=UTF-8 (SOAP1.1)
    • Content-Type: application/soap+xml; charset=UTF-8 (SOAP1.2)
  • SOAPAction (HTTP header)
    • SOAPAction:"urn:HeartBeat" (SOAP1.1)
    • action="urn:HeartBeat" (SOAP1.2 an optional attribute to the Content-Type header)
  • Envelope namespace (Payload / Content)
    • <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> (SOAP1.1)
    • <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> (SOAP1.2)

According to https://wso2.com/library/176/, Axis2 will use the following to determine the SOAP operation to invoke:

  • HTTP request uri
  • SOAPAction
  • QName of the first child of SOAP Body element
  • If WS-Addressing is enabled the address of To EPR (Endpoint Reference) and Action element

With the example above, Axis2 will determine the SOAP operation with the following:

InfoValue
HTTP request uri/myservice
SOAPActionurn:HeartBeat
QName of the first child of SOAP Body element<ns1:HeartBeat>

If the request uri consist of two parts “part1/part2”, it will be interpreted as “service-end-point/operation”. Our example above contains only the service-end-point, thus, the request uri cannot tell us the operation to invoked.

The SOAPAction urn:HeartBeat is a clear indicator for the operation to invoke. In our example above, Axis2 will use it to determine the SOAP operation.

The QName of the first child of SOAP Body element <ns1:HeartBeat> can also be used by Axis2 to determine the SOAP operation.