A SOAP message is a well-formed XML document that contains an Envelope element, an optional Header element, and a mandatory Body element, as Figure 4.4 shows.
The Envelope element serves as a container for the Body and Header elements and also as an indicator to the processing node that the XML is a SOAP message. The key use of the envelope is to indicate the start and end of the message to the receiver. Once the receiver comes across the </Envelope> tag, it knows the message has ended and can start processing it (or picking up the attachments, if any). The envelope is essentially just a packaging structure.
The Header element is optional, but if present, it should be the first immediate child element of the Envelope element. SOAP does not define any individual header entries or XML elements in the header block. This is a key feature that many other specifications exploit by standardizing on the entries. This means that to add some functionality, the new specifications can define headers the SOAP message will carry and that vendor implementations of that specification can use in a standard manner. For example, the header may also contain meta-data entries that help describe or augment the main content of the SOAP message, or information on how to route the message to different paths, add security, and so on.
The Body contains the actual, mandatory message intended for the final recipient. This may be XML elements that describe a procedure invocation-for example, describing arguments and parameters along with a procedure name-or other XML content, such as a complete purchase order. These two different techniques are generically called RPC-style and document-style SOAP messaging, respectively.
As Figure 4.2 shows, a SOAP message has to be layered on top of a transport protocol. The rules that pertain to how a SOAP message is to be sent over a particular protocol are called the SOAP binding to that protocol. While the header elements may determine how a SOAP node processes the message, the protocol binding framework determines how a message travels between processing nodes.