SOAP message format

Schema for the SOAP 1.1 message can be found in here.
This says all about the SOAP message format.

Example SOAP message


<?xml version="1.0"?>
<soap:Envelopexmlns: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.example.org/stock">
  <m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>
</soap:Body>

</soap:Envelope>

Code obtained from W3Schools.com


Identification of the elements in SOAP message


xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
===> XML name space, soap is referenced at a schema whihc is at the given URI

soap:Envelope
===> Envelop is the root element at any SOAP xml message

soap:Body 
===>  Body is where the content of the message is held

xmlns:m="http://www.example.org/stock
===> Another xml namespce , m is declared. The scheme is at the given URI

<m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>

===> This is the actual message. (ex: stock name is IBM)


















https://upload.wikimedia.org/wikipedia/commons/thumb/5/59/SOAP.svg/220px-SOAP.svg.png


SOAP message elements

  • Envelope - Must be there
  • Header - optional (Meta data. Documentation, time stamps etc)
  • Body - Must be there 
  • Fault - optional (child element of Body. can contains error messages and error codes, error details)

SOAP data types

All the specifications for SOAP data types can be found in here in details.
http://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes
http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383514

primitive data types used in SOAP

  • string
  • boolean
  • decimal
  • float
  • double
  • duration
  • dateTime
  • time
  • date
  • gYearMonth
  • gYear
  • gMonthDay
  • gDay
  • gMonth
  • hexBinary
  • base64Binary
  • anyURI
  • QName
  • NOTATION
When we use a SOAP library (at client side or server side) it can match with the data used in applications and SOAP primitive data types. These  data types should be defined in WSDL when used with a service.

SOAP supports complex data types too. Complex datatypes structure should be defined in WSDL.
Share:

0 comments: