SOAP


SOAP is an XML format for transmitting data to and from a Web service. An automated tool creates the SOAP file, which includes details from the WSDL definition. For details on SOAP that go beyond our introduction, see the following primer: http://www.w3.org/TR/2003/REC-soap12-part0-20030624.

SOAP Format

The major elements in the transmitted SOAP message are as follows:

  • the Envelope element, which is the root and usually includes namespace declarations.

  • the Header element, which includes Quality of Service details. The Header element is optional; if it is present, each of its immediate children is called a header block.

  • the Body element, which includes business data.

Listing 5.11 depicts the overall structure of a SOAP message.

Listing 5.11: Structure of a SOAP message

image from book
 <Envelope>    <Header>       <!- header blocks go here ->    </Header>    <Body>       <!- business data goes here ->    </Body> </Envelope> 
image from book

Example

We created the SOAP output shown in Listing 5.12 using IBM Rational Application Developer.

Listing 5.12: Sample SOAP output

image from book
 <SOAP-ENV:Envelope    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"    xmlns:q0="http://www.dmv.org/"    xmlns:xsd="http://www.w3.org/2001/XMLSchema"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">    <SOAP-ENV:Body>       <q0:getMotorVehicleRecord>          <VIN>A123</VIN>          <State>NC</State>          <Category>sport</Category>       </q0:getMotorVehicleRecord>    </SOAP-ENV:Body> </SOAP-ENV:Envelope> 
image from book

The Envelope element start-tag includes namespace details. The prefixes SOAP-ENV, xsd, and xsi are commonplace, even though this specific SOAP transmission doesn't use them. Use of the q0 prefix (in place of the WSDL-specific tns prefix) is a detail specific to Rational Application Developer. At the other end of the transmission, the namespace Universal Resource Identifier (URI) is important, but the identity of the prefix that references the URI is not.

Header Blocks

As Web-based SOA runtimes become more advanced, header blocks will become more important; and the content of those blocks will increasingly conform to the open-standard WS-* specifications being developed by various organizations.

The header block can include details that are needed to fulfill the kind of QoS options described in Chapter 2. The block can also indicate whether conditional processing is required, as when the service returns a log of its activity during some invocations but not others.

You can set header blocks explicitly in the WSDL file that contributes to the SOAP message. More likely, however, is that your SOA runtime product adds header blocks in accordance with data structures and values that are established at configuration time.

The extra details provided by header blocks may not be meaningful at a particular intermediary or at the final destination. To allow you to control a variety of cases, SOAP lets you set the following attributes in any header block:

  • The mustUnderstand attribute indicates whether a given SOAP engine (a kind of XML processor) must handle the header block. By default, the value of false is transmitted, which means that handling is not required.

  • The actor attribute identifies the SOAP engine to which the mustUnderstand attribute applies. By default, mustUnderstand applies to the message's final destination.

A SOAP engine that handles a header block must remove that block, although the processor can always add the equivalent header block or any other.

In SOAP 1.2, the role attribute replaces actor and identifies, not an intermediary, but a specific role whose name and purpose are defined by an intermediary. As in Version 1.1, however, the default behavior is to process the header block at the message's final destination.

Like business data, the data in a header block usually conforms to an XML Schema definition.




SOA for the Business Developer. Concepts, BPEL, and SCA
SOA for the Business Developer: Concepts, BPEL, and SCA (Business Developers series)
ISBN: 1583470654
EAN: 2147483647
Year: 2004
Pages: 157
Authors: Ben Margolis

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net