Anatomy of a SOAP Message

The SOAP specification describes four major components: formatting conventions for encapsulating data and routing directions in the form of an envelope, a transport or protocol binding, encoding rules, and an RPC mechanism. The envelope defines a convention for describing the contents of a message, which in turn has implications on how it gets processed. A protocol binding provides a generic mechanism for sending a SOAP envelope via a lower-level protocol such as HTTP. Encoding rules provide a convention for mapping various application datatypes into an XML tag-based representation. Finally, the RPC mechanism provides a way to represent remote procedure calls and their return values. Throughout this book, we’ll refer to these four areas collectively as a SOAP message .

How XML Becomes SOAP

We start this discussion by focusing on the document exchange model. To clarify this topic, we use a simple purchase order document, PO.xml . This document is overly simplified because it contains only two things—a ship-to address and an item entry:

<?xml version="1.0" encoding="UTF-8"?>
<PurchaseOrder xmlns="urn:oreilly-jaws-samples">
    <shipTo country="US">
        <name>Joe Smith</name>
        <street>14 Oak Park</street>
        <city>Bedford</city>
        <state>MA</state>
        <zip>01730</zip>
    </shipTo>
    <items>
        <item partNum="872-AA">
            <productName>Candy Canes</productName>
            <quantity>444</quantity>
            <price>1.68</price>
            <comment>I want candy!</comment>
        </item>
    </items>
</PurchaseOrder>

PO.xml is not yet ...

Get Java Web Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.