Home > Articles > Web Services > XML

  • Print
  • + Share This
From the author of

SOAP Messages

SOAP defines an XML vocabulary for exchanging messages as well as a protocol for interaction. As illustrated in Figure 2, SOAP messages are contained in an envelope. Envelopes contain an optional header and the body of the message. Headers contain relevant information about the message. For example, a header can contain the date the message is sent, or perhaps authentication information. While the header is not required, if present it always appears at the top of the envelope.

Figure 2

Figure 2 It’s a packaging format. It’s a protocol. It’s SOAP!

Looking ahead to a world where ZwiftBooks supports a web service to provide quotes using SOAP, following is an example of how a client might format a SOAP message to request a quote from ZwiftBooks based on ZIP code and ISBN:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Body>
 <getQuote xmlns="http://zwiftbooks.com/ws ">
  <isbn>012345678</isbn>
  <zip>90210</zip>
 </getQuote>
 </soap:Body>
</soap:Envelope>

In the above SOAP request, notice that namespaces are used to distinguish between SOAP elements and elements defined by ZwiftBooks. Following is a sample of how the ZwiftBooks web service might reply:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Body>
 <getQuoteResponse xmlns="http://zwiftbooks.com/ws">
  <getQuoteResult>

  <isbn>012345678</isbn>
  <price>58.00</price>
  <hours>2</hours>
  <pricetime>58.00/2 hours</pricetime>

  </getQuoteResult>
 </getQuoteResponse>
 </soap:Body>
</soap:Envelope>
  • + Share This
  • 🔖 Save To Your Account