Tuesday, November 27, 2012

RESTful web service


REST - Representational State Transfer

In the REST architectural style, data and functionality are considered resources and are accessed using Uniform resource Identifiers.
In the REST architectural style, clients and servers exchange representations of resource by using standardized interface and protocol.

The pricnciples supports the RESTful webservices to be simple, leightweight and fast.

1. Resource identification through URI :
- exposes a set of resources that identify the target of the interaction with its clients.
- resources are identified by URIs
2. Uniform Interface
- resources are manipulated using CRU operations : PUT, GET, POST and DELETE
PUT - creates a new resource
GET - retrieves the current state of a resource in some representation.
DELETE - deletes the resource.
POST - transferes a new state on to a resource.
3. Self Descriptive Messages
- resources are decoupled from their representation so that their content can be accessed in a variety of formats.
- Metadata about the resources are available.
4. Stateful interactions through hyperlink.
- every interaction with a resource is staeless.
- request messages are self contained.

Root resource classes
- POJOs
- annotated with @Path
or atleast one method annotated with @Path
or request method designator - @GET/ @PUT/ @POST/ @DELETE

- Resource methods - methods of a resource class annotated with a request method designator.

No comments:

Post a Comment