java2db

RESTful web service example in java using JAX-RS



RESTful web services are lightweight and fast to access that are made to work best for Web based applications.We used jersey to create RESTful web service example in java.

RESTful web service example in java using JAX-RS (Eclipse , GlassFish)Basic requirements to develop RESTful web service example in java :

Softwares :
Java (Download).
GlassFish server (Download).
Eclipse IDE (Download).
Jar files:
jersey-client.jar (Download).
jersey-common.jar (Download).
jersey-container-servlet.jar (Download).
jersey-container-servlet-core.jar (Download).
jersey-media-jaxb.jar (Download).
jersey-server.jar (Download).
servlet-api-2.4.jar (Download).

 

RESTful web service example in java using JAX-RS (Eclipse , GlassFish)In the example , we used Jersey jars released from Oracle, If you want ,you can use RESTEasy  from Jboss and others.

 

 

 

RESTful web service example in java using JAX-RS (Eclipse , GlassFish) Step 1 :

Create a dynamic web project in any  IDE like Eclipse , NetBeans , MyEclipse , RAD .

Crate a java class ( HelloWorld .java) , jsp file (index.jsp) and web.xml like below and copy the source code.

Add all the jar files to the lib folder.

 

 

WSDL in java Web Services

 

 index.jsp

 

RESTful web service example in java using JAX-RS (Eclipse , GlassFish) HelloWorld .java

 

 web.xml

 

 

 

 Step 2 :

Deploy the above dynamic web project in any web/application server like GlassFish , Tomcat , WebSphere , Wildfly or JBoss.

 

WSDL in java Web Services

 

 

 Step 3 :

Test the RESful web service application with its URL.

Enter URL (localhost:9090/RESTfulWebServiceExample/index.jsp) in the browser address bar .

After successful submit , you will get the below screen.

 

WSDL in java Web Services

 

 

 

 Step 4 :

Click the link to call the resource of the RESTful web service . Finally the web service return the below result.

 

WSDL in java Web Services

From the above (screen) response URI ,

localhost : Is the IP address (127.0.01).

9090 : Is the server port.

RESTfulWebServiceExample : Project name (Web application name).

hello :  Is the <url-pattern>  that configured in the web.xml file .

welcome : Is the resource path that configured in the HelloWorld .java class (@Path(“welcome”))




Related Posts :
How to Connect to Oracle from Liferay portlet ( Java Liferay and Oracle integration )
How to Connect Liferay 7 to PostgreSQL ( Java Liferay portlet and PostgreSQL integration )
How to call C# .Net WCF web service in java SOAP client ( Visual Studio 2013 )
How to call PHP RESTful web service in java client
How to call java SOAP web service in php ( php web service client )
Solution to SSLHandshakeException (skip the certificate for Java and LDAP bind)
How to create a java client to call RESTful web service JAX-RS (Jersey )
Example java RESTful web service for xml response (JAX-RS , Jersey)
   [will not be published]



^ <