REpresentational State Tranfer ( REST ) by itself is not an architecture. It defines a set of rules and constrains, when applied while designing an application, create a software architectural style. The application will have peculiar roles defined for data, components, hyperlinks ( URI ), protocols and data consumers on the other side. REST shows a path to develop a distributed application using the networking resources and technologies. A system can be defined as RESTful if it has the following characteristics
- A client - server model
- Stateless - which means users sessions need not be maintained, independent requests should be made available.
- A caching system supportive
- Should not be dependent on networking infrastructure
- Resources should be defined and accessed using unique URI's
- Should be scalable
- Should provide code on demand
- APIs should be exposed or published.
The following will form the core fundamental blocks of RESTful web services
- Resources ( addressable over the Web )
- Data representation ( XML / JSON )
- URI ( Uniform Resource Identifiers )
- Uniform interfaces through HTTP requests.
Main areas where Web Services deployment is implement worthy
- Within companies to support operations.
- Expose the API's to the public
- Distributed system development where a client can be on a web or a mobile device or cloud access.
- A consistent data distribution requirement
Amazon offers its on-demand hosting storage infrastructure using web service. Facebook offers its platforms for targeted marketing and advertising campaigns. Web Service when they are implemented in companies for operations will be used to connect previously disjointed departments within the company. By connecting more than one department to share information using web services, a new system will be put in place by the same Service Oriented Architecture ( SOA ). The first principle of REST is the idea of using Hypermedia As The Engine of Application Engine ( HATEOAS ). Hypermedia is a document-centric approach with added support for adding links to other services and information.
A brief about JX-RS
- JAX-RS framework focusses on applying Java annotations to plain Java objects.
- It has annotations to bind specific URI patterns and HTTP operations to the respective and individual methods in the Java resources ( classes ).
- It has parameter injection annotation which makes the job easy to pull in the required information from the client accessing the web service.
- It has message body headers that allows marshalling and unmarshalling daya from the Java data objects.
- It has exception mappers that will map the application thrown exceptions to an HTTP response code and message.
To close this, a one line quote about Web Services would be, " It is an independent computing system that exchanges data in XML / JSON formats with other systems using HTTP as the communication protocol and it implements a single business requirement"