add

Web Services – part 3

Introduction to Web Services

As discussed earlier in article : Web Services Basics – part 2 , we can generally use a web service to expose our application’s functionality over the internet and also can make specific methods in our service consumable to other applications provided , the consuming application must have the understanding of contract of inputs and outputs provided by the publisher application.

Another benefit of Web Services is that it makes possible for re-use the service as many times we need. Once a web Service is exposed to the outside world, All the consumer applications can start accessing the same service as many times they want.

We will be discussing here two popular Web Services approach ( though we have many) which are vendor neutral standards for commonly  accessing the Web Services.

a) Simple Object Access Protocol (SOAP)  :

SOAP is a W3C-recommended vendor neutral -platform independent and XML based specification for sending and receiving messages between applications over the web.

Since XML doesn’t confirm to a structure and disparate applications are not sure of an agreeable format , SOAP follows a well defined XML structure format in which request and response messages can be exchanged between sender and receiver applications.

Standard  SOAP Structure  looks like below :

A sample SOAP request message ( if you take our Fictious use case tourism App ) shown below :

<?xml version=”1.0″ encoding=”utf-8″?>
<soap:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/”>
<soap:Body>
<flightRequest  xmlns=”http://www.fictiousAirline.com/search”  flow=”search” >
<source>Chicago</source>
<destination>california</destination>
<routeType>oneway</routeType>
<travelDate>30-JUN-18</travelDate>
</soap:Body>
</soap:Envelope>

Above SOAP XML request message sample has “Envelope” root node and Body element has the details for our search criteria.

The resulting data is returned again in SOAP ML Format as per SOAP Specification.

sample SOAP Response :

<?xml version=”1.0″ encoding=”utf-8″?>
<soap:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/”>
<soap:Body>
<flightresponse xmlns=”http://www.fictiousAirline.com/search flow=”search”>
<flightName>T345</flightName>
<flightdate>30-JUN-18</flightdate>
<flighttime>12:30AM</flighttime>
<source>chicago</source>
<destination>california</destination>
<price>120$</price>
</flightResponse>
</soap:Body>
</soap:Envelope>

A Typical SOAP Request/Response Scenario over HTTP Protocol :

SOAP request/response over HTTP.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

It can use any transport mechanism to send and receive the messages. For Example :  HTTP or TCP. ( even over JMS too). SOAP most often uses the HTTP transport protocol to take advantage of passing through firewalls as they pass on common port 80.

Written by Ramesh Metta


Leave a Reply

Your email address will not be published. Required fields are marked *

*
*