What is REST?
REST- Representational State TransferThe REST architecture involves client and server. When the client requests for the resource, which is exposed by the server, the server responses the representation. The representation of the resource can be in JSON,XML, plain text and HTML etc...
The resource can be identified with the meaningful URI.
For example, the user details whose age is between 25 to 50 are need to be fetched from the host . Then the resource URI can be designed as
http://
The REST architecture depends on the HTTP methods. The REST uses the HTTP methods such as GET,PUT,POST,DELETE for performing the CRUD operations. The details of these operation are described below.
Pros:
- The applications can interchange the data using the RESTful web services irrespective of the language and platform used by the other application.- The RESTful applications leave the room for the scalability of the application.
- It is light web services provider compared to JAX-WS which uses SOAP. The JAX-RS(Restful web services) uses only the standard HTTP methods. The advantages of REST over REST can be found at Advantages of REST over SOAP.
Cons:
- It has the limitation of using only the HTTP methods(GET,POST,PUT,DELETE). Complex operations are difficult to perform.- On World Wide Web, clients can cache the responses. Which makes the client to receive the stale data.
HTTP Method | Description | JAX-RS annotation |
---|---|---|
GET | Get method is used only to retrieve the information represented by the resource(URI). Some times, the GET method can return cache or stale data as because GET request responses are cached by the browser to reduce un necessary network calls | @GET is the JAX-RS annotation equivalent for the HTTP GET method. |
PUT | PUT is used to create the resource at the specified URI. If the request URI does not exist then the resource can be created. If a resource is already exits at the request URI then the existing resource can be replaced with the requested. The server responds with 201 - resource created,200 - OK, 204 - No content | @PUT is an equivalent JAX-RS annotation for HTTP PUT method |
POST | The URI at the POST request will handle the request. It is usually used for modifying a resource. | @POST is an equivalent JAX-RS annotation for HTTP POST method |
DELETE | The resource at the requested URI will be deleted. The server responds with the 200(OK) and similar responses if the request for delete is successful by the time of response by server. | @DELETE is an equivalent JAX-RS annotation for HTTP DELETE method |
The Restful web services tutorial with Jersey can be found at RESTful web services tutorial
No comments:
Post a Comment