RestfulWS


REST  - REpresentational State Transfer. it is an architectural style.
            - stateless client-server architecture.
            -webservices are idetified by their URIs
            - rest is stateless(i.e., server contains no client state. but cachable);
            -Java API for RestFul webservice is JAX-RS. and used annotations to simplify the                                  development of webservices.
            -basic implementations of JAX-RS are
                    1. Jersey (implemented by SUN)      2. RESTEasy (implemented by JBOSS)


Rest Webservices Annotations:

- @Path : to specify relative path of class and methods.

-Http Request Methods :
@GET, @POST, @PUT, @DELETE and @HEAD

GET - carries request parameters which are appended in URL.
         - GET is basically used for  fetching(retrieving) data.
         - GET request can be cached and also bookmarked.

POST - Carries request parameters in message body. which is more secure way of transfer data.
           - POST is used to create(store) new resource.
           - POST Request or Responses are not cachable.
           - POST is not idempotent method.

PUT - replacing the existing resource or creating if resource is not available(preferred for update).
         - Idempotent method (always same result).
         - If the client is responsible for creating the IDs of resource then PUT method can be used                  create.
        - can cache the response.

DELETE - to delete resources(identified by requestURI).
                - Idempotent method and from second time of delete, will get 404 status from                                        response(Not  found).  response are not cache-able.

HEAD - checks whether a resource has changed.
            - retrieves metadata about the resource (ex: mediaType or size before retrival).

OPTIONS - Identifying which HTTP methods a resource supports.
                  - returns info about API(methods/contentType..etc)






Page1



Page2

No comments:

Post a Comment

JAVA NOTES

  click here  👉  Interview  Preparation : complete notes sql queries notes ============================================================ Con...