Explain SOAP protocol ?
SOAP defines the XML messages exchanged between the consumer and the provider . SOAP is the standard web services application protocol. It gives the communication mechanism to connect web services and exchanging formatted XML data across a network protocol, commonly HTTP.
Like WSDL, SOAP relies heavily on XML because a SOAP message is an XML document containing several elements ( envelope, header, body, etc). Instead of using HTTP to request a web page from a browser, SOAP sends an XML message via a HTTP request and receives a reply via a HTTP response.
SOAP is designed to connect to a distributed services and these connected services can be built by using whatever/any combination of hardware and software that supports a given transport protocol.
Whereas SOAP can be used in a different messaging systems and can be sent via a variety of protocols, the priority of SOAP is remote procedure calls transported via HTTP.
By SOAP client applications are easily connect to remote services and invoke the remote methods.
Frameworks, like CORBA, DCOM, and Java RMI, give same functionality to the SOAP, but SOAP messages are written completely in XML so they are language and platform independent.
Describe the SOAP Message Structure along with their elements ?
A SOAP XML document instance, which is called a SOAP message, is generally carried as the charge/payload of some other protocol.
For example, the most common way to exchange SOAP messages is via HTTP, used by web browsers to access HTML web pages. SOAP messages are exchanged between applications on a network. HTTP is a useful way of sending and receiving SOAP Messages. By other network protocol these messages are carried out, such as FTP and raw TCP/IP.
A SOAP message is a type of XML document. SOAP has its own Namespace, XML schema and processing rules. A SOAP message is analogous to an envelope used in postal service. A SOAP message contains XML data. XML namespaces are used to keep SOAP specific elements separate.
A Soap message have a XML declaration, that states the version of XML and the format:
< ?xml version=”1.0″ encoding=”UTF”?>
If an XML declaration is used, the version of XML must be 1.0 and the encoding must be UTF-8 or UTF 16. If encoding is not present, the SOAP message is based on XML 1.0 and the UTF-8. An XML declaration is not mandatory.
A SOAP message contain the following elements:
Envelope
It defines the message and the namespace used in the document. This is a compulsory root element.
Header
It enclose any optional attributes of the message or application-specific infrastructure such as security information or network routing.
Body
It include the message being exchanged between applications.
Fault
It gives information about errors that occur while the message is handled. This is optional element.
A SOAP Message Structure :
[code lang=”xml”]
<?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:Fault>
…
</soap:Fault>
</soap:Body>
</soap:Envelope>
[/code]
SOAP defines in what way messages can be structured and processed by a software that is independent of any programming language and thus aid interoperability between applications written in different languages that running on different operating systems.