A RESTFul web services are based on HTTP methods. A RESTFul web service typically defines the base URI for the services, the supported MIME-types (text, JSON,XML, user-defined, …) and supports POST, GET, PUT, DELETE .
RESTful web services using Jersey / JAX-RS
This tutorial will explain how to make REST webservices using Jersey / JAX-RS, I have used eclipse, Jersey 2.11 / JAX-RS 2.0.
When we should use REST
When we want to minimize the coupling between client and server.it is mainly use in distributed system.
Suppose we want to develop a mobile apps, we may not store the data in mobile or we may not do the complex computing in mobile, so we can use the REST and get the data from server.
Now follow the below steps to make a sample Rest webservices, here I am showing just GET and POST . hope it will help you to learn the REST webservices.
Project structure should be as below.
The filter (AccessFilter) is not mandatory. If you are accessing the REST out side the server then you make have to provide the access details.
For every services you have to provide the access, to avoid the writing access related code again and again I have written the code in filter.
How to test.
There are many way to test the webservices . but I will show here how to do test using “advance rest client”. That is apps for chrome. If you do not have rest client in chrome please search in google and install it.
Now click on Advanced REST client.
Provide the url , OPTION, content-Type and click on send.
Test with Jquery
alert(“Check the Java console”);
For test the REST in Jquery please download the rest code and import in eclipse.
Run the rest in tomcat.