SOAP (Simple Object Access Protocol) is a simple XML-based protocol to let applications exchange information over HTTP. It is basically designed to access Web Services effectively and easily.
Today’s applications communicate using Remote Procedure Calls (RPC) between objects like DCOM and CORBA, but HTTP was not designed for this. RPC represents a compatibility and security problem; firewalls and proxy servers will normally block this kind of traffic. A better way to communicate between applications is over HTTP, because HTTP is supported by all Internet browsers and servers. SOAP was created to accomplish this. SOAP provides a way to communicate between applications running on different operating systems, with different technologies and programming languages.
Talking about the syntax rules of SOAP, a SOAP message MUST be encoded using XML using the SOAP envelope namespace. Besides, a SOAP message should not contain any DTD reference and should also not contain XML Processing Instructions.
A sample skeleton SOAP message is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.google.com/2011/05/soap-envelope" soap:encodingStyle="http://www.google.com/2011/05/soap-encoding"> <soap:Header> ... </soap:Header> <soap:Body> ... <soap:Fault> ... </soap:Fault> </soap:Body> </soap:Envelope> |
The required SOAP Envelope element is the root element of a SOAP message. This element defines the XML document as a SOAP message. For example:
1 2 3 4 5 6 7 8 |
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.google.com/2011/05/soap-envelope" soap:encodingStyle="http://www.google.com/2011/05/soap-encoding"> ... Message information goes here ... </soap:Envelope> |
Notice the xmlns:soap namespace in the example above. It should always have the value of: “http://www.google.com/2001/12/soap-envelope”. The namespace defines the Envelope as a SOAP Envelope. If a different namespace is used, the application generates an error and discards the message.
A very important attribute is encodingStyle attribute which is used to define the data types used in the document. This attribute may appear on any SOAP element, and applies to the element’s contents and all child elements. It’s syntax is:
soap:encodingStyle=”URI”
In a future article, we would discuss some more important features of SOAP.