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!

No comments:

Post a Comment