Introduction and Architecture of RESTful Web Services

Restful Web Services

Web service uses to transfer data from one system to another System over an HTTP protocol. HTTP protocol is used to transfer message or data over the web.

Web Service Architecture

 Components of Web Service

  1. WSDL
  2. UDDI
  3. STUDS
  4. SOAP Protocol
  5. HTTP

You can relate the diagram which helps you to understand how web service exchange data over the web. The information is exchanged between client application and server.

Let’s suppose we have java file on server side. It contains method “add”. WSDL is an XML file which contains a class name, method name, parameter type and return type. WSDL Generation tool is an API which helps to generate WSDL file. To handover this WSDL(XML) file we have to register this file to UDDI Registry. It creates a unique id and passes it client so that client can know about the service class, its method and all other information which are required to exchange data.

Through stubs executive tool, STUBS id created which store service class method. An object of the stub is created on the client side which calls the method. stubs executive tool is also An API. You can see in the diagram on client side STUB object “obj” is created which call the “add method”.

Stubs and client are always written in the same language. If the client is written in java then stubs are written in Java. Stub have all the method which define in service class from the WSDL file. When the client invokes the method “add”, method details will store in the ‘SOAP REQ’(as you can see in the diagram).

Now this SOAP REQ handover to the server over HTTP(HyperText Transfer Protocol). HTTP is a transfer protocol which helps to transfer data over the internet. Sever pass ‘SOAP REQ’ to Skeleton, which is an API. Skeleton will have all the method details from which it can invoke ‘add’ method and store the result. Skeleton create a ‘SOAP RES’ which contain result and transfer the result to Stub through HTTP. The stub will read the value and assign the value to the variable ‘res’.

This is the complete process how communication happens b/w client and server.

Restful Web Services

Web service is of two different types.

  1. SOAP WS
  2. REST WS

In this article, we will discuss RESTful web service. REST stands for Representational State Transfer. Rest is an architecture style (client-server) for developing an application that can be accessed over the net. It is platform independent. Rest based application can be written in any language. We can have a different type of data formats to transfer data such as text, JSON, XML, HTML.

In REST every content is treated as a ‘Resource’. These resources can be text files, HTML page, image etc.

Key components of RESTful Web Service:

  1. Resources: it can be text files, XML, JSON, images etc.
  2. Request Verbs: tells what you want to do with the resource. It can be GET, POST, PUT, and DELETE.
  3. Request Header: it provides the additional information send with the resources and define the type of response required.
  4. Request Body: data sent to the resource.
  5. Response Body: Response sends by the resource to the request.
  6. Response status code: the code return along with the request.

 Methods used in RESTFul Web Service

Let’s take an example to understand it better. We are using a location where restful web service already defines. Let it be a student entry form.

  1. Post: when any new student enters its detail, it will transport over the web.
  2. Get: To fetch the value of all student.
  3. Delete: to delete the details of the relevant student.
  4. PUT: this is used to update the details of the relevant student.

Stateless architecture is followed by Rest. Stateless means state of application not maintained. State of the client application or request is not stored by the server. Because of its simplicity REST, WS is getting popular. Rest WS use existing HTTP method to transfer data.  It is used to build Web service lightweight, saleable and maintainable.

Difference between Rest and Soap Web Service.

Rest is an architecture-style.  Soap is a protocol.
Rest can use Soap WS because it can use any protocol. Soap cannot use rest because It is a protocol and Rest is an architectural style.
Use URI to expose service. Use service interface to expose business logic.
Require less bandwidth and resource than Soap Require more bandwidth and resource than Rest.
Permits different data formats such as XML, JSON Permit XML data format only.

Please write your comment and also ask query in the comment section. We will love to solve them.

Introduction and Architecture of RESTful Web Services
Tagged on:

Leave a Reply

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