This document gives a rough and incomplete overview of SOAP 1.2.
|
Note
|
The reader supposedly has basic knowledge of HTTP and XML. |
The Simple Object Access Protocol (SOAP) specification defines (non exhaustive list):
-
an abstract exchange protocol of (specific species of) XML Infosets;
-
a binding that specifies how those XML Infosets are to be serialized (and more, see below).
-
An XML Infoset is an abstract data type. Serialization transforms the XML Infoset into a concrete representation in bytes.
-
An obvious example of serialization of an XML Infoset is the XML serialization (
<book><title>Sir</title></book>), but others are conceivable (some encrypted serialization for example) or exist. As an example, the W3C SOAP Message Transmission Optimization Mechanism (MTOM) spec defines an optimized serialization of SOAP messages.
SOAP typically transmits SOAP messages. A SOAP message is a species of XML Infoset. It has an env:Envelope root element, which may contain two sub-elements. (The env prefix corresponds to the namespace name http://www.w3.org/2003/05/soap-envelope.)
-
The
env:Headeroptional sub-element may serve to give informations to SOAP processing nodes (and may be altered by those nodes) on the way from the initial sender to the ultimate receiver. -
The
env:Bodymandatory sub-element has application-specific content. It is empty or contains a sub-element from a possibly application-specific namespace.
See example 1 (from SOAP spec part 1).
A binding makes SOAP transmission concrete. It specifies:
-
how to serialize XML Infosets;
-
mechanisms to support features (that extend the transmission protocol), such as the SOAP Web Method feature, the Message Exchange Patterns (MEPs) feature (see below), or the SOAP Action feature (not explained here).
The spec specifies what a SOAP binding is in general (see above), and specifies one such concrete binding, namely the HTTP one.
This binding has two MEPs (that consist in further specifying the two basic MEPs seen above).
-
SOAP Response: an HTTP
GETfollowed by an HTTP response that contains a SOAP message as a body; -
SOAP Request-Response: an HTTP
POSTcontaining a SOAP body, followed by a response as above.
The application/soap+xml media type is (typically) used in those exchanges.
Despite forceful argumentation in the spec in favor of applying the SOAP Response MEP when appropriate, most implementations only consider the SOAP Request-Response MEP (possibly with an empty body in the request).
The spec defines how SOAP may be used for Remote Procedure Calls (RPCs).
-
A procedure is viewed as a named operation that has input parameters, output parameters, possibly a return value, and fault types (that can be used instead of outputs and return values). Some parameters may be both input and output.
-
A RPC invocation has, as SOAP body, a struct named after the invoked operation and with children corresponding to the input parameters.
-
A RPC response has, as SOAP body, a struct with a child
responsein namespacehttp://www.w3.org/2003/05/soap-rpc(if the procedure declares a return value) and other children for other output parameters. -
Encoding of such structs into the SOAP body is left to be defined by the application.
-
W3C SOAP recommendation
-
W3C SOAP primer (I recommend it, it’s clear and short)
-
Web Services Interoperability (WS-I) Basic Profile (BP) clarifies and modifies SOAP and related specifications to promote interoperability.
The spec defines a specific encoding, SOAP encoding, for structs used in RPCs, but it is not used anymore. (See WSDL in brief.)
A SOAP Web Method is one of GET, POST, PUT, DELETE, understood as their HTTP equivalent. The SOAP Web Method feature permits to specify which SOAP Web Method is to be used for a given SOAP message exchange. This feature is available for use in any binding.
The HTTP binding also requires support for the SOAP Action feature and for the SOAP Web Method feature. The latter is restricted to value "GET" or "POST", depending on the chosen MEP.
The SOAP spec permits multiple elements inside a body element inside the envelope, but BP R9981 modifies this.
SOAP 1.1 uses the http://schemas.xmlsoap.org/soap/envelope/ namespace and text/xml instead of application/soap+xml media type.