SCDJWS Study Guide: SOAP


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend


Previous Next vertical dots separating previous/next from contents/index/pdf Contents

SOAP Body

The Body element contains the payload of the message, that is, the part intended for the final recipient of the SOAP message.  The Body element is encoded as an immediate child element of the SOAP Envelope XML element. If there is no Header element, then the Body element is the first immediate child of the Envelope element. If a Header element is present in the message, then the Body element MUST immediately follow the Header element.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/"
targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"> .... <xs:complexType name="Body">
<xs:sequence>
<xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
</xs:sequence>
<xs:anyAttribute namespace="##any" processContents="lax">
<xs:annotation>
<xs:documentation>
Prose in the spec does not specify that attributes are allowed on the Body element </xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
....
</xs:schema>

The Body element can have one or more namespace-qualified immediate child elements that are not in the http://schemas.xmlsoap.org/soap/envelope/ namespace or, if a fault occurred, a Fault element in the http://schemas.xmlsoap.org/soap/envelope/ namespace.

All immediate child elements of the Body element are called body entries and each body entry is encoded as an independent element within the Body element. A body entry is identified by its fully qualified element name, which consists of the namespace URI and the local name. Immediate child elements of the SOAP Body element MAY be namespace-qualified. SOAP defines one body entry, which is the Fault entry used for reporting errors.

<soap:Envelope
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<h:from xmlns:h="http://www.wrox.com/Header">SoapGuy@wrox.com</h:from>
</soap:Header>
<soap:Body>
<w:GetSecretIdentity xmlns:w="http://www.wrox.com/heroes/">
<w:codename>XSLT-Man</w:codename>
</w:GetSecretIdentity>
</soap:Body>
</soap:Envelope>

The encoding rules for body entries are as follows:

  • A body entry is identified by its fully qualified element name, which consists of the namespace URI and the local name. Immediate child elements of the SOAP Body element MAY be namespace-qualified. 

NOTE: WS-I BP 1.0 requires all immediate children of Body element be namespace qualified.

  • The SOAP encodingStyle attribute MAY be used to indicate the encoding style used for the body entries (this attribute MAY appear on any element, and is scoped to that element's contents and all child elements not themselves containing such an attribute, much as an XML namespace declaration is scoped).


Previous Next vertical dots separating previous/next from contents/index/pdf Contents

  |   |