What is REST Services :

Definition : 1

  • The REST stands for Representational State Transfer.
  • REST is a set of principles that define how Web standards, such as HTTP and URLs, are supposed to be used.

Definition : 2

In simple, REST is a architectural style construct based on the principle using the Web fundamentals.

From msdn,

  • An architectural style, sometimes called an architectural pattern, is a set of principles.
  • An architectural style improves partitioning and promotes design reuse by providing solutions to frequently recurring problems.
  • You can think of architecture styles and patterns as sets of principles that shape an application.

Let we see Fundamentals/principles details

Resource :

In REST,  every thing will be treat as resource, for example

www.aadharsh.com/image/birthday (image resource)
www.aadharsh.com/user/GKA (Dynamically pulled resource)
www.aadharsh.com/audio/audfile (audio resource)

from above, first URL shows the image resource as the output… same thing for all other URL with different identifiers. Here image/audio/video/static page… every thing are treated as resource instead of thinking physical file/data.


Unique identifier

Every resources identifies by an URL, in earlier for identify all the resource by URL.
For example to identify the user detail we use like below

www.aadharsh.com/GetUserDetails.aspx

Now in REST, added one more constrain. That is every resources  must represent by an unique URL, For example

www.aadharsh.com/GetUserDetails/Kavi
www.aadharsh.com/GetUserDetails/Gnanamurugan

Here if we want to get the user detail for the kavi then we can get GetUserDetails/Kavi in same way for other users ( we want to append username at the end) not as before like this

www.aadharsh.com/GetUserDetails?Name=Kavi
Instead of using Generic page, REST point the unique identifiers to identify the resource

Uniform Interface :

Use simple and uniform interface, for example if client want to Add/Insert/Select/Delete user detail, we use like below method name to perform the above operation

  •   AddUserDetails (it combine with PUT)
  •   InsertUserDetails (it combine with PUT)
  •   SelectUserDetails (it combine with GET)
  •   DeleteUserDetails (it combine with DELETE)

When we watch closely the method name, it seems to be inconsistent and difficult to remember,so REST says to uses simple and uniform interface. This can be obtain by the uniform methods of HTTP protocol and combine the name with the resource operation.Let we see the HTTP protocol methods

  •  GET : Get the Resource
  •  PUT : Create/Update the resource
  •  DELETE : Delete the resource
  •  POST : submit the data to the resource

Communication should be representation :

Representation is nothing but request and response between the client and the server.

Stateless :

Each request from client to server must contain all the information necessary to understand the request, and cannot take advantage of any stored context on the server. In simple, HTTP have nothing to indicates when a session starts or ends.