Deploying POJO Class as a Web Service using Axis2


 

Under construction……………………………………………………………………………………….

 

 

Hi Everybody. This is my first post in my blog. This post contains how, we can use Axis2 framework for implementing web services.

First of all I will give you brief introduction about what is Axis2 and advantages of using Axis2 over other frameworks like Spring Web services, Metro web service framework. Axis2 is much matured web service framework when compared to others. It supports almost all WS standards; it supports HTTP, JMS and SMTP transport layers etc. AXIS2 is a framework for developing web services and it  is a Web service/ SOAP / WSDL  engine. If you previously used any other frameworks for developing web services you will really appreciate axis2 development team once you get used with axis2 because you don’t have to worry about how to develop a web service. Axis2 lets you concentrate on developing your business logic rather than kill yourself by writing huge amount of coding. Ok, I think I gave enough introductions about AXIS2 framework. Now let’s see an example of how can we develop a web service using a simple POJO class.

What this web service will do is echo back the given String.

 

Step1: Write a

Step1 : Write a java class which you want to expose as a webservice.

 

package com.wordpress.narendrakadali.examples.axis2;

 

/**

* HelloWorld.java

*

* @author : Narendra
Kadali narendra.kadali@hotmail.com

*/

public
class HelloWorld

{


/**

* Operation in HellowWorld web service

*

* @param str

* : Takes a String

* @return : Given input string

*/


public String echoHelloWorldService(String str)

{


return str;

}

}

 

Step2: write services.xml as follows.

 

<serviceGroup>

    <service
name=“HellowWorld”>

        <description>

            This is a sample Web Services developed using Axis2

        </description>

        <parameter
name=“ServiceClass”>com.wordpress.narendrakadali.examples.axis2.HelloWorld

        </parameter>

        <messageReceivers>

            <messageReceiver
mep=http://www.w3.org/2004/08/wsdl/in-only&#8221;

                class=“org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver”
/>

            <messageReceiver
mep=http://www.w3.org/2004/08/wsdl/in-out&#8221;

                class=“org.apache.axis2.rpc.receivers.RPCMessageReceiver”
/>

        </messageReceivers>

    </service>

</serviceGroup>

 

The <service
name=“HellowWorld”> tag indicates that the web service name is HellowWorld and <parameter
name=“ServiceClass”> indicated the fully classified class name of java class which is going to be exposed as a web service.

 

 

Step3: Place it in services Folder

Place this services.xml in a META-INF folder and aar it. I mean jar them and you can change file extension to aar.

 

That’s it. You are ready to deploy it. For additional info on this please refer to the following link http://axis.apache.org/axis2/java/core/docs/pojoguide.html

 

 

 


 

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: