Service Oriented Architecture | Komputasi | Suatu Permulaan

Chapter 8 • Web Services 267 • A binding to HTTP, to ensure that the XML message is transported correctly • The conventions for conveying an error in message processing back to the sender

8.2.1 The SOAP Message Format

A unit of communication in SOAP is a message. A SOAP message is an ordinary XML document containing the following elements Figure 8-3: • A required Envelope element that identifies the XML document as a SOAP message • An optional Header element that contains the message header information; can include any number of header blocks simply referred to as headers; used to pass additional processing or control information e.g., authentication, information related to transaction control, quality of service, and service billing and accounting-related data • A required Body element that contains the remote method call or response information; all immediate children of the Body element are body blocks typically referred to simply as bodies • An optional Fault element that provides information about errors that occurred while processing the message SOAP messages are encoded using XML and must not contain DTD references or XML processing instructions. Figure 8-4 illustrates the detailed schema for SOAP messages using the notation introduced in Figure 6-5. If a header is present in the message, it must be the first immediate child of the Envelope element. The Body element either directly follows the Header element or must be the first immediate child of the Envelope element if no header is present. Because the root element Envelope is uniquely identified by its namespace, it allows processing tools to immediately determine whether a given XML document is a SOAP message. The main information the sender wants to transmit to the receiver should be in the body of the message. Any additional information needed for intermediate processing or added-value services e.g., authentication, security, transaction control, or tracing and auditing goes into the header. This is the common approach for communication protocols. The header contains information that SOAP envelope SOAP header SOAP body body block body block header block header block attachment block attachment block Actual message content required Processing instructions Context information optional Identifies message as a SOAP message required Arbitrary content optional Envelope Envelope Body Body Header Header header blocks body blocks attachment blocks Envelope Envelope Body Body Header Header header blocks body blocks attachment blocks Figure 8-3: Schematic representation of a SOAP message. Highlighted are the required elements. Ivan Marsic • Rutgers University 268 can be used by intermediate nodes along the SOAP message path. The payload or body is the actual message being conveyed. This is the reason why the header is optional. Each of the SOAP elements Envelope, Header, or Body can include arbitrary number of any elements. Recall that the any element enables us to extend the XML document with elements not specified by the schema. Its namespace is indicated as other, which implies elements from any namespace that is not the namespace of the parent element, that is, soap- env . An example SOAP message containing a SOAP header block and a SOAP body is given as: Listing 8-1: Example of a SOAP message. 1 soap-env:Envelope 2 xmlns:soap-env=http:www.w3.org200305soap-envelope 3 xmlns:xsd=http:www.w3.org2001XMLSchema 4 xmlns:xsi=http:www.w3.org2001XMLSchema-instance 5 soap-env:Header 6 ac:alertcontrol xmlns:ac=http:example.orgalertcontrol 7 soap-env:mustUnderstand=1 8 ac:priorityhighac:priority 9 ac:expires2006-22-00T14:00:00-05:00ac:expires 10 ac:alertcontrol 11 soap-env:Header 12 soap-env:Body 13 a:notify xmlns:a=http:example.orgalert 14 a:note xsi:type=xsd:string Global attributes: Envelope ? soap-env: Envelope soap-env: Header soap-env: Body ? other: any Envelope ? soap-env: Envelope soap-env: Envelope soap-env: Header soap-env: Body ? other: any Header soap-env: Header ? other: any other: anyAttribute ? Header soap-env: Header ? other: any other: anyAttribute ? Body soap-env: Body ? other: any other: anyAttribute ? Body soap-env: Body ? other: any other: anyAttribute ? soap-env: role soap-env: mustUnderstand soap-env: encodingStyle soap-env: relay soap-env: role soap-env: mustUnderstand soap-env: encodingStyle soap-env: relay Fault soap-env: Fault Code Reason Node Role Detail ? ? ? Fault soap-env: Fault Code Reason Node Role Detail ? ? ? Figure 8-4: The XML schema for SOAP messages. The graphical notation is given in Figure 6-5. SOAP version 1.2 schema definition available at: http:www.w3.org200305soap-envelope .