SOAP - Envelope



The SOAP envelope indicates the start and the end of the message so that the receiver knows when an entire message has been received. The SOAP envelope solves the problem of knowing when you are done receiving a message and are ready to process it. The SOAP envelope is therefore basically a packaging mechanism.

Points to Note

  • Every SOAP message has a root Envelope element.

  • Envelope is a mandatory part of SOAP message.

  • Every Envelope element must contain exactly one Body element.

  • If an Envelope contains a Header element, it must contain no more than one, and it must appear as the first child of the Envelope, before the Body.

  • The envelope changes when SOAP versions change.

  • The SOAP envelope is specified using the ENV namespace prefix and the Envelope element.

  • The optional SOAP encoding is also specified using a namespace name and the optional encodingStyle element, which could also point to an encoding style other than the SOAP one.

  • A v1.1-compliant SOAP processor generates a fault upon receiving a message containing the v1.2 envelope namespace.

  • A v1.2-compliant SOAP processor generates a VersionMismatch fault if it receives a message that does not include the v1.2 envelope namespace.

v1.2-Compliant SOAP Message

Given below is an example of v1.2-compliant SOAP message.

<?xml version = "1.0"?>
<SOAP-ENV:Envelope 
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope" 
   SOAP-ENV:encodingStyle = " http://www.w3.org/2001/12/soap-encoding">
   ...
   Message information goes here
   ...
</SOAP-ENV:Envelope>

SOAP with HTTP POST

The following example illustrates the use of a SOAP message within an HTTP POST operation, which sends the message to the server. It shows the namespaces for the envelope schema definition and for the schema definition of the encoding rules. The OrderEntry reference in the HTTP header is the name of the program to be invoked at the tutorialspoint.com website.

POST /OrderEntry HTTP/1.1
Host: www.tutorialspoint.com
Content-Type: application/soap;  charset="utf-8"
Content-Length: nnnn

<?xml version = "1.0"?>
<SOAP-ENV:Envelope 
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope" 
   SOAP-ENV:encodingStyle = " http://www.w3.org/2001/12/soap-encoding">
   ...
   Message information goes here
   ...
</SOAP-ENV:Envelope>

NOTE − The HTTP binding specifies the location of the service.

Advertisements