How to implement RESTful Web Services in Java.

RESTful services is used for creating, maintaining, retrieving, and deleting resources. A resource can be anything of potential interest that is serializable in some form like a file, query, calculation, or concept. This form is called a representation.

Developing RESTful Web services that support exposing your data in a variety of representation media types and abstract away the low-level details of the client-server communication is not an easy task without a good toolkit. In order to simplify development of RESTful Web services and their clients in Java, a standard and portable JAX-RS API has been designed.

Tomcat and jetty are both Java Application Server. They don’t provide specific support for REST/SOAP technologies. They are just Servlet Container.

Spring framework is a lightweight framework helping you to bring everything together. Configuring all your components etc. It provide built-in support for REST/SOAP, but it can also be integrated with more powerful-webservice-dedicated frameworks.

REST implementation, you can use Jersey – a JAX-RS (JSR 311) reference implementation . It can be integrated with Spring quite easily.

For SOAP : you can look at apache CXF (it also provide support for REST)

1. JAX-RS: Java API for RESTful Web Services is a Java programming language API that provides support in creating web services according to the Representational State Transfer (REST) architectural pattern. JAX-RS uses annotations, introduced in Java SE 5, to simplify the development and deployment of web service clients and endpoints.

For non-Java EE 6 environments a (small) entry in the web.xml deployment descriptor is required.

2. Spring – MVC (spring 3.0 onwards): Spring’s annotation-based MVC framework serves as the basis for creating RESTful Web Services. As such, you configure your servlet container as you would for a Spring MVC application using Spring’s DispatcherServlet.

3. Axis2:  Axis2 supports for RESTfull services. It implements the most defined HTTP binding specification. REST Web services are a reduced subset of the usual Web service stack.

When REST Web services are accessed via GET, the service and the operations are identified based on the URL.
POST based Web services do not need a SOAP Envelope or a SOAP Body. REST Web Services do not have Headers and the payload is sent directly.

Gopal Das
Follow me

Leave a Reply

Your email address will not be published. Required fields are marked *