Wednesday, September 25, 2013

How to deploy a jax-rs service in WSO2 Application Server and send request via Advanced Rest Client



Hello all,

In my previous post I have described how to write a simple jax-rs service using WSO2 Developer Studio.

In this post lets see how we can deploy the service using WSO2 Application Server and send request using Advanced Rest Client.

First of all you will have to download the Application Server from the WSO2 product page.

Extract the product to a local folder and run the server. You can refer to this previous post on how to start the server.

Once the server is started, go to the management control and type admin, admin to login as username and password respectively.

Then go to


2. Upload the .war file

When the service is deployed you can see the service in application list.



When you click on the service you deployed in the list, you can get the following view where you can see the service details.













Get the service endpoint url and give the service path in the Advanced Rest Client to send the requests as represented in the following image.















See y'all next time. Cheers!

Tuesday, September 24, 2013

How to create a jax-rs service using WSO2 Developer Studio

Hi All,

Today we are going to talk about how to create a jax-rs service using WSO2 Developer Studio.

First of all you have to download the WSO2 Developer Studio form the WSO2 product page.

Developer studio comes as a plugin for eclips.
Using Developer Studio it is really easy to create the service and deploy.
Once you have WSO2 Developer Studio Downloaded, extract the content to a local folder. Then open eclips.

There you can find “Developer Studio” on the top menu bar and select open dashboard.
Here you have to select JSX-RS Service Project.


Select Create New JAX-RS Service and click Next.


Fill in the project details


Then click on finish.


Then the environment for the jax-rs service project will be created.

Here we are creating a simple service with User Object class and service class to get user information.
You can create a simple user object class as follows with defining it as the root element.



Developer Studio provides the options to auto generate the getters and setters as well.
 

Then you can write the jax-rs service using the object creted as User as follows:-

When you are writing a jax-rs service, the attention should be given to jax-rs annotations.
You can see that the @Path element is set for the service and two @GET methods are written each having the specific @Path defined.



You can follow the below links to read more about jax-rs and xml annoatations:-


Once the service is completed, you can simply deploy it by right clicking on the project -> and selecting Export Project as Deployable Archive.


Here you can mention the path you want to create the .war file.


See you next time. Cheers!