DEV Community

Cover image for Let's Learn - Week 1 - SOAP
Dinakar
Dinakar

Posted on • Updated on

Let's Learn - Week 1 - SOAP

Introduction to SOAP Web Services

SOAP is an acronym for Simple Object Access Protocol.
SOAP defines specific way of building web services.
We use XML as request and response exchange format.

Any request that contains XML as request and response is not SOAP.
SOAP defines specific XML request and response structure.

SOAP

We need to create SOAP envelope that contains header and body.
The header contains meta information like authentication , authorization etc.
SOAP body is where we put real content of request and response.

The service definition is managed by WSDL – Web Service Description Language

Examples of SOAP Request , Response & WSDL

SOAP Request

<?xml version="1.0"?>

<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Header/>
<soap:Body xmlns:m="http://www.example.org/stock">
  <m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>
</soap:Body>
</soap:Envelope>

SOAP Response

<?xml version="1.0"?>

<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">

<soap:Body xmlns:m="http://www.example.org/stock">
  <m:GetStockPriceResponse>
    <m:Price>34.5</m:Price>
  </m:GetStockPriceResponse>
</soap:Body>

</soap:Envelope>

WSDL

<message name="getTermRequest">
  <part name="term" type="xs:string"/>
</message>

<message name="getTermResponse">
  <part name="value" type="xs:string"/>
</message>

<portType name="glossaryTerms">
  <operation name="getTerm">
    <input message="getTermRequest"/>
    <output message="getTermResponse"/>
  </operation>
</portType>

Now that we have an idea about SOAP based web services , let's move to Restful Web Services

Top comments (0)