Tuesday, September 13, 2016

REST:Representational state transfer

What is REST ?

REST stands for REpresentational State Transfer. REST is web standards based architecture and uses HTTP Protocol for data communication. It revolves around resource where every component is a resource and a resource is accessed by a common interface using HTTP standard methods. REST was first introduced by Roy Fielding in 2000.
In REST architecture, a REST Server simply provides access to resources and REST client accesses and presents the resources. Here each resource is identified by URIs/ global IDs. REST uses various representations to represent a resource like text, JSON and XML. Now a days JSON is the most popular format being used in web services.

HTTP Methods

Following well known HTTP methods are commonly used in REST based architecture.
  • GET - Provides a read only access to a resource.
  • PUT - Used to create a new resource.
  • DELETE - Used to remove a resource.
  • POST - Used to update a existing resource or create a new resource.
  • OPTIONS - Used to get the supported operations on a resource.

RESTFul Web Services

A web service is a collection of open protocols and standards used for exchanging data between applications or systems. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer. This interoperability (e.g., between Java and Python, or Windows and Linux applications) is due to the use of open standards.
Web services based on REST Architecture are known as RESTful web services. These web services use HTTP methods to implement the concept of REST architecture. A RESTful web service usually defines a URI, Uniform Resource Identifier a service, provides resource representation such as JSON and set of HTTP Methods.

Creating RESTFul Web Service

This tutorial will create a web service say user management with following functionalities:
Sr. No.HTTP MethodURIOperationOperation Type
1GET/UserService/usersGet list of usersRead Only
2GET/UserService/users/1Get User with Id 1Read Only
3PUT/UserService/users/2Insert User with Id 2Idempotent
4POST/UserService/users/2Update User with Id 2N/A
5DELETE/UserService/users/1Delete User with Id 1Idempotent
6OPTIONS/UserService/usersList the supported operations in web serviceRead Only

No comments:

Post a Comment