Friday, February 01, 2008

Restful Web Service

Web service is designed to communicate with machine to machine. Web service is defined by W3C "as software system designed to support inter operable machine to machine interaction". There are different architecture of the web service like REST full resource oriented, RCP-style and REST-RCP hybrid.

Roy Fielding articulated REST as an underlying concept for today's Web architecture. The most important concept of the REST is it is architecture style not the protocol i,e There is no REST specification, no tools from SUN, IBM or Microsoft, it uses the exiting technology for creating web service. It is not standard it use the standard.

Who are using RESTFul web service

  • Services that expose the Atom Publishing Protocol (http://www.ietf.org/html.charters/atompub-charter.html) and its variants such as GData (http://code.google.com/apis/gdata/)
  • Amazon’s Simple Storage Service (S3) (http://aws.amazon.com/s3
  • Most of Yahoo!’s web services (http://developer.yahoo.com/)

All application are based on the representation state transfer. For amazon, after get the book id any one can get the book detail through the id.

What is the representation state transfer:
The web is the composed of resource. For example, University defined the student resource with their id(99301). Student can access the resource through the url

Year Dept Roll
99 3 01

http://www.university.edu/information/99301

The representation of the resource is returned through the url(99301.html). The client get new position of the state. By the new representation of the resource, client get another state. In this way, client change their state.

Creating RESTFul Web Service
For creating RESTFul web service need to identify all the resource that need to expose as the web service. Some example, student list, student detail. Use exiting http operation for accessing and creating the resource.

Http Operation
GET Accessing the resource
POST Create
PUT Update
DELETE Delete

Get the university student list:

http://www.university.edu/information/students
It will return all the student id list of the university.

The client receive the following document



xmlns:xlink="http://www.w3.org/1999/xlink">






Get details list:
http://www.university.edu/information/students/99301

It will return the detail list of the student.

In RCP based web service need to create client stubs in the client side and different method access the resource to the server but in the REST based, methods are the fixed(get, post, put, delete), no need to generate client stub to access the web service in the client side. Using browser
method get access all resource.

No comments: