SOAP is a communication protocol between applications. It allows
them to exchange information (messages) over HTTP via Internet, based
on XML. SOAP stands for Simple Object Access Protocol.
A SOAP message is an XML document that must not contain a DTD
reference. It contains the following elements:
- An Envelope namespace element as s SOAP message (the root)
- A Header element (optional)
- A Body element containing call and response information
- A Fault element that provides information about errors (optional)
2. General structure:
The general structure of a SOAP message is:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header>
....
</soap:Header>
<soap:Body>
...
</soap:Body>
<soap:Fault>
...
</soap:Fault>
</soap:Body>
</soap:Envelope>
3. Some details:
<soap:Header>
-------------
If it is present: It will be the first child that contains
information as authentication ...
Inside SOAP Header, we find the following
XML element that define how the recipient should process
the SOAP message:
<m:ELEMENT xmlns:m="http://www.w3schools.com/transaction/"
soap:ATTRIBUTE="VALUE">VALUES</m:ELEMENT>
The attribute can be: actor (argument:URL), mustUnderstand
(argument:0 or 1), or encodingStyle (argument:URL).
</soap:Header>
<soap:Body>
----------
Here the required message to the ultimate endpoint.
<m:askingFor xmlns:m="URL">
<m:book>The Times</m:book>
</m:askingFor>
(askingFor, book, or The Times are not SOAP standard)
The feedback could be:
<m:available xmlns:m="URL">
<m:theBook>The Times, with 120 pages.</m:theBook>
</m:available>
(available, theBook, or The Times are not SOAP standard)
</soap:Body>
<soap:Fault>
-------------
Here go error messages ...
With also the following children:
<faultcode> (to define the fault), <faultstring> (explanation of the fault),
<faultactor>(who caused the fault) and <detail> (foe details).
</soap:Fault>
</soap:Body>
</soap:Envelope>
4. The SOAP Protocol:
SOAP operates as the HTTP communicating over the TCP/IP (using
request by GET or POST methods), in XML. The user send a message along with the protocol
containing: POST, Host, Content-Type, and Content-Length. The server validates the message
by Content-Length with the value 0 if the server could not decode the request).
HTTP POST request uses two required headers: Content-Type and Content-Length.
SOAP adds an extra information (MIME type) in the Content-Type, like
this:
Content-Type: MIMEType; charset=character-encoding
The character encoding is optional.
5. Example:
The SOAP request:
POST /Books HTTP/1.1
Host: www.books.net
Content-Type: application/soap+xml; charset=utf-8
Content-Length: xxx