Saturday, 1 April 2017

Understanding Web Services: SOAP & REST

What is a Web Service?

Web service is a way of calling of a function which is inside a software from some other software.
The software which gives a call is called a client and the software which serves the request is called the server. This two software's need not to be written in same programming language. client can be written in java and the server can be written in .NET. This two software's need not to be on the same machine, but their should be network connecting client and the server.

For example if two software want to communicate as shown in the figure then the two
things are required.

1. Medium: It is used to transfer the data between the two software's or client and the server.
LAN, Internet can be used as a medium using some protocols like HTTP to established the connection.

2. Format of Input and Output Messages: The format is very important to transfer the
data between the two software's. Here we used two protocols SOAP (Simple Object Access Protocol) and REST (Representational State Transfer).

Client and Server is the architecture for the web Service. Client is the service consumer while the Server is the service provider. Service provider means the web services are deployed on the server. The Web Services have some functions int it which can be used by the rest of the world.


For example, suppose the server have four functions in the Web Service. So, to access these Web Service  and the functions the client needs to know the following constructs.

1. Location of the web services server.
2. Some more info describing the web services

  •    Signature of the functions
  •    Standards used by these Web Services.

There are two types of Web Services

1. SOAP
2. REST


SOAP


All the above details the service provider captures in a xml file and known as WSDL (Web Services Description Language) and make this file available to the client.

So, client need a xml file that is WSDL file to access the web services.

How the client locate the WSDL file on the internet for the particular service provider?
  • If service provider knows the client then service provider directly gives the WSDL file to the client.
  • There is a entity called UDDI (Universal Description Discovery and Integration). Its a directory on the internet where all the service providers who wants to issue there web services on internet first need to register the web services with the UDDI using WSDL.

The Procedure:

1. Client Searches for a service in UDDI
2. UDDI returns all the service providers offering that service.
3. Clent chooses one service provider and gets WSDL
4. With the help of WSDL, cleint access the webservices.

REST


REST (Representation State Transfer) is a set of guidelines which talks about how a client should
interact with the server. Suppose the client wants to access the RESTful web service then the REST guidelines says that the data and functionality which the client can access on server is known as resource. The resource must be accessed using its URI's (Uniform Resource Identifier) by all the clients.

The Procedure:

1. Client sens a request
2. Server gives the response as the representation of a Resource (Data & Functionality).
A resource can be presented in many formats like HTML, XML, plain text, PDF, JPEG, JSON etc.

Features:
  • Cleint directoly access a Resource using its URI
  • Self-description messages
  • Uniform Interface

The communication protocol which RESTful web services uses is HTTP. REST guidelines talks about stateless communication between client and the server which means every single request is treated as new request and should contains all the information needed to establish a communication. Since HTTP best describes stateless communication protocol, RESTful web service uses this protocol. However there is no restrictions specified in the REST guidelines for using the kind of protocol. So we can use any other communication protocol.

Uses four HTTP methods

  1. GET Retrive a resource
  2. POST Create a resource
  3. PUT Update a resource
  4. DELETE Delete a resource


Difference between REST and SOAP

  • REST is more dynamic, no need for creating and updating UDDI.
  • SOAP only support XML, but REST supports different format like text, JSON, XML etc. 
  • SOAP is a protocol. REST is an architectural style.

The main advantages of REST web services are:

  •    Lightweight - not a lot of extra xml markup
  •    Human Readable Results
  •    Easy to build - no toolkits required


The main advantages of SOAP web services are:

  •     Easy to consume - sometimes
  •     Rigid - type checking, adheres to a contract
  •     Development tools







6 comments:

  1. I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post.
    Best facials in Manhattan

    ReplyDelete
  2. The computerized organization likewise conveys crosswise over tasks which look for online pursuit of employment and enlistment administrations. AMP

    ReplyDelete
  3. Fantastic post. Lots of useful info here. Thanks for sharing amazing tips. If you want to hire the best Ecommerce Website Development Company In India in india,Please visit Our Website.

    ReplyDelete
  4. Remarkable post. I simply came across your blog and desired to say that I have really enjoyed searching your blog posts. Thank you for sharing such blogs. website design

    ReplyDelete