A SOAP message is encoded as an XML document, consisting
of an <Envelope> element, which contains an optional <Header>
element, and a mandatory <Body> element. The <Fault> element,
contained in the <Body>, is used for reporting errors.
The SOAP envelope
The SOAP <Envelope> is the root element in every SOAP message.
It contains two child elements, an optional <Header>, and a mandatory <Body>.
The SOAP header
The SOAP <Header> is an optional subelement of the SOAP envelope.
It is used to pass application-related information that is to be processed
by SOAP nodes along the message path.
The SOAP body
The SOAP <Body> is a mandatory subelement of the SOAP envelope.
It contains information intended for the ultimate recipient of the
message.
The SOAP fault
The SOAP <Fault> is a subelement of the SOAP body, which is
used for reporting errors.
With the exception of the <Fault> element, which
is contained in the <Body> of a SOAP message, XML elements in the <Header>
and the <Body> are defined by the applications that make use of
them. However, the SOAP specification imposes some constraints on
their structure.
Figure 1 shows the
main elements of a SOAP message.
Figure 2 is an example of a
SOAP message that contains header blocks (the <m:reservation> and <n:passenger> elements)
and a body (containing the <p:itinerary> and <q:lodging> elements).