SOAP

From NoskeWiki
Jump to: navigation, search

About SOAP

SOAP or Simple Object Access Protocol, is an Extensible Markup Language (XML) based protocol (system) for exchanging information between computers over HTTP. Think of SOAP as special XML (plaintext) messages send over the web - typically between a client and server program. Since SOAP messages are sent via HTTP or STMP they rarely have firewall issues (HTTP is supported by all Internet browsers and servers), and will work on any platform / operating system, so long as both programs know how to interpret your SOAP messages. Fortunately SOAP libraries have exist for most programming languages and should take care of most of the headaches once you learn how to use them.

On this page I have tried to summarize (mostly for myself) how SOAP works and recorded links to useful pages about SOAP - especially the great articles about SOAP by w3school.com.


Example SOAP Message

Each (XML) SOAP message contains:

Here's a skeleton of what such a message looks like:

<?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>


And an example of SOAP request message is here:

<?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:Body>
  <m:GetPrice xmlns:m="http://www.w3schools.com/prices">
    <m:Item>Apples</m:Item>
  </m:GetPrice>
</soap:Body>
 
</soap:Envelope>

And the reply:

<?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:Body>
  <m:GetPriceResponse xmlns:m="http://www.w3schools.com/prices">
    <m:Price>1.90</m:Price>
  </m:GetPriceResponse>
</soap:Body>
 
</soap:Envelope>

This example requests the price of apples. Note that the "m:GetPrice" and the "m:Item" elements above are application-specific elements - they are not a part of the SOAP namespace.


Picking a SOAP Library

To write SOAP clients and servers, one can use almost any programming language, but really you want to first check that someone has written a good set of libraries. Writing your own library to send, receive and translate these XML message is something you have great coding prowess and a lot of time on your hands. Good SOAP libraries not only let you send and receive messages, but should also contain tools which can take a WSDL file and generate skeleton classes. WSDL files are described in the page listed below.


Links

  • WSDL - a file format used to define SOAP messages used by your application(s)


Links