Monday, August 12, 2013

Java WebService Tutorial - Part 10 (REST WebService Basic Overview)


Hi again , So far we have discussed writing Web Service using SOAP Messages , along with WSDL and Schema's , now we are going to look into the next type of Web Service which gain Popularity these days used by Google,Amazon and others called REST Style Web Services.

What is REST Web Service?
  •  REST Stand for Representational State Transfer means state is not maintain it is a stateless Service.  
  •  A REST  Web Service is very light weight and easy to create Service.
  •  It is use along with the HTTP Protocol.
  •  Do not Require XML Messaging or WSDL & XSD Schema's.

REST is Useful in the following Scenarios: 
  •  Web Service is completely Stateless.A good test is interaction is survive a restart of Server.
  •  Caching Infrastructure can be leveraged for performance.
  •  Service Provider and Service Consumer have mutually understand the  context and content being passed along.
  • Bandwidth is particularly important ,need to be limited. REST is particularly useful for limited Profile devices such as PDA & Mobile devices.  
  • Well Suited  for creating API for client spread out across Internet.
  • REST Architecture Style is designed to use a Stateless communication protocol ,typically HTTP .In REST Client and Server exchange Representation of Resources by using a Standardized Interface and Protocol.

JAX-RS(REST)  VS JAX-WS (SOAP) :

JAX - WS :
  • Addressed advanced Quality of Service (QOS) commonly occuring in the enterprise computing.
  • Comparing JAX-RS , JAX-WS easier to support WS-* ,set of protocols, provide standard way of Security and reliability.
Note : To know more about JAX-WS please refer  http://ayazroomy-java.blogspot.in/2013/08/java-webservice-tutorial-part-09.html

JAX - RS:
  •  Easier to write Web Applications , apply some or all of the constraint of REST Style . 
  • Loosely coupled, Scalable, Simple to maintain.

Principles of REST  :

1. Resource Identification through URI :

As for REST is concern every thing here is access as resource, and  resources are identified by  URI which comes as part of the URL .Which provide a global addressing space for resources and services discovery using @Path Annotations(we will discuss this annotation in next part).

Ex:

http://localhost:7001/home/student/jack

here student and jack is URI part of the URL.

2. Uniform Interface :

Resources are manipulated using fixed set of Operations . GET,PUT,POST,DELETE.

GET : Retrieves the current state of resource in some representation (xml/json)

POST : Transfer a new state on to a resource.

PUT : Create a new resource which can be deleted by DELETE.

DELETE : Use to delete a Resource.

All these operations are provided by HTTP protocol .


3. Self Descriptive Messages : 

Resources are decoupled from their representation so that their content can be accessed in variety of format such as HTML,XML,JSON,IMAGE etc.


4. Stateful Interaction through links :

Every Interaction with the resource is stateless , that is request message is self contained.

Stateful Interaction can be done based upon the concept of explicit State Transfer.

Several techniques are there to exchange state , such as URI - Rewriting, cookies, hidden fields etc.


JERSEY Framework :
  • Jersey is the Production ready frame work for REST to create the Services quick and fast.
  • Developing REST Webservice using Jersey is inexpensive and thus have very low barrier for adoption.
  • Jersey also provide support for JAXB and also provides libraries for creating and manipulating JSON.
  • Jersey support Annotations.

In the next part we will see how to create a simple REST Service ...


 << Prev                                  Index                                        Next >> 
--------------------------------------------------------------------------------------------------------------
 









8 comments:

  1. Wow, this article has important programming information that has helped not only to finish my programming assignment but to also to learn new programming skills. Thanks so much for sharing the article with us and I will be visiting this site occasionally to read more articles. Find time and read my article by clicking on Literature Review Writing Help.

    ReplyDelete
  2. tidak perlu khawatir karena cara mendaftarnya sangat mudah. Di dalam situs permainan umumnya telah tersedia rangkuman cara mendaftar untuk orang yang belum memiliki pengalaman.
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme terbaik
    hobiqq
    paito warna terlengkap
    syair sgp

    ReplyDelete