REST Webservices

RESTful Web Services are basically REST Architecture based Web Services. In REST Architecture everything is a resource. RESTful web services are light weight, highly scalable and maintainable and are very commonly used to create APIs for web-based applications.

REST Architecture :

A concrete implementation of a REST Web service follows four basic design principles:

  • Use HTTP methods explicitly.
  • Be stateless.
  • Expose directory structure-like URIs.
  • Transfer XML, JavaScript Object Notation (JSON), or both.

1.  Use HTTP methods explicitly

This basic REST design principle establishes a one-to-one mapping between create, read, update, and delete (CRUD) operations and HTTP methods. According to this mapping:

  • To create a resource on the server, use POST.
  • To retrieve a resource, use GET.
  • To change the state of a resource or to update it, use PUT.
  • To remove or delete a resource, use DELETE.

2. Be stateless

Statelessness in this sense improves Web service performance and simplifies the design and implementation of server-side components because the absence of state on the server removes the need to synchronize session data with an external application.

Stateful Design :

Stateful Design

Stateless Design :

Stateless Design

3. Expose directory structure-like URIs.

REST Web service URIs should be intuitive to the point where they are easy to guess. Think of a URI as a kind of self-documenting interface that requires little, if any, explanation or reference for a developer to understand what it points to and to derive related resources. To this end, the structure of a URI should be straightforward, predictable, and easily understood.

For Example :{topic}

Some additional guidelines to make note of while thinking about URI structure for a RESTful Web service are:

  • Hide the server-side scripting technology file extensions (.jsp, .php, .asp), if any, so you can port to something else without changing the URIs.
  • Keep everything lowercase.
  • Substitute spaces with hyphens or underscores (one or the other).
  • Avoid query strings as much as you can.

URIs should also be static so that when the resource changes or the implementation of the service changes, the link stays the same.

4. Transfer XML, JavaScript Object Notation (JSON), or both

A resource representation typically reflects the current state of a resource, and its attributes, at the time a client application requests it.

The last set of constraints that goes into a RESTful Web service design has to do with the format of the data that the application and service exchange in the request/response payload or in the HTTP body. This is where it really pays to keep things simple, human-readable, and connected.

Listing 6. XML representation of a discussion thread









<?xml version=”1.0″?>

<discussion date=”{date}” topic=”{topic}”>



   <reply from=”” href=”/discussion/topics/{topic}/joe”/>

   <reply from=”” href=”/discussion/topics/{topic}/bob”/>



Table 1. Common MIME types used by RESTful services
MIME- Type Content-Type
JSON application/json
XML application/xml
XHTML application/xhtml+xml

Source : 


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s