Saturday 12 February 2011

Simple Object Access Protocol - SOAP

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




<?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">
  ...
  Message information goes here
  ...
</soap:Envelope>


soap:encodingStyle="URI" 
[This encodingStyle attribute is used to define the data types used in the document]


soap:mustUnderstand="0|1"
[This SOAP mustUnderstand attribute can be used to indicate whether a header entry is mandatory or optional 
for the recipient to process.
If we add mustUnderstand="1" to a child element of the Header element 
it indicates that the receiver processing the Header must recognize the element.]


A SOAP Request


POST /InStock HTTP/1.1
Host: www.opsecsecurity.com/stock
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn


<?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 xmlns:m="http://www.opsecsecurity.com/stock">
  <m:GetStockPrice>
    <m:StockName>Applied Holographics</m:StockName>
  </m:GetStockPrice>
</soap:Body>


</soap:Envelope>








A SOAP Response:


HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn


<?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 xmlns:m="http://www.opsecsecurity.com/stock">
  <m:GetStockPriceResponse>
    <m:Price>42</m:Price>
  </m:GetStockPriceResponse>
</soap:Body>


</soap:Envelope>






---






soap:actor="URI"
[This SOAP actor attribute is used to address the Header element to a specific endpoint.]
<?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">


[Question]
<soap:Body>
  <m:GetPrice xmlns:m="http://www.ba.com/prices">
    <m:Item>Dubai</m:Item>
  </m:GetPrice>
</soap:Body>


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


[Answer]
<soap:Body>
  <m:GetPriceResponse xmlns:m="http://www.ba.com/prices">
    <m:Price>1000.00</m:Price>
  </m:GetPriceResponse>
</soap:Body>


</soap:Envelope>


</soap:Envelope>


[HTTP Protocol Question]
POST /item HTTP/1.1
Host: 192.168.2.4
Content-Type: text/plain
Content-Length: 200


[HTTP Protocol Answer]
200 OK
Content-Type: text/plain
Content-Length: 200

1 comment:

Anonymous said...

SOAP is used in the business world and is an established standard for exchanging information.