Build Web Service Application with Axis2

 

We talked about the old fashion and how about the new one? For my understanding, the key difference from the earlier version is, Axis2 provides very convenient container to look after the web service application. With Axis2, you would no longer need to call the AdminClient to deploy the service like what we did earlier.

 

Axis2 container is deployed on the application server no difference with the other web applications. The place you need to deploy your web service application is webapps/axis2/WEB-INF/services. There are two options for your deployment, either deploy as Plain Old Java Objects (POJO) or deploy as .aar file.

 

For POJO deployment, you should have your application structure complaint to the following.

 

ws.JPG

 

There are three mandatory components

  • lib – to hold all necessary libraries file for you application
  • META-INF – it should hold a services.xml file, which tells Axis how to deploy the service
  • Compiled (POJO) class files – where you hold your service logic

 

Here is an example of the services.xml file. Make sure the “name” attribute of service tag should be identical to the directory name of your application and the value for ServiceClass should be the implementation class of the service.

<service name="xxxx" scope="application">

    <description>

        Sample Service

    </description>

    <messageReceivers>

        <messageReceiver

            mep="http://www.w3.org/2004/08/wsdl/in-only&quot;

    class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>

        <messageReceiver

            mep="http://www.w3.org/2004/08/wsdl/in-out&quot;

    class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>

    </messageReceivers>

    <parameter name="ServiceClass">com.xxx.xxx.xxxx.webservice.xxxSoapBindingImpl

    </parameter>

</service>

 

Alternatively, you could deploy your application as a .aar file. The preceding plugin (axistools-maven-plugin) has helped us to get the compiled code from WSDL file. We can carry on our work with it and build the .aar file with another plugin

    <plugin>

           <groupId>org.apache.axis2</groupId>

           <artifactId>axis2-aar-maven-plugin</artifactId>

           <version>1.4</version>

           <executions>

                  <execution>

                        <goals>

                               <goal>aar</goal>

                        </goals>

                  </execution>

           </executions>

           <configuration>

                  <fileSets>

                        <fileSet>

                               <directory>../</directory>

                               <outputDirectory>META-INF</outputDirectory>

                               <includes>

                                      <include>*.xml</include>

                               </includes>

                        </fileSet>                              

                  </fileSets>

           </configuration>

    </plugin>

 

http://ws.apache.org/axis2/tools/1_4/maven-plugins/maven-aar-plugin.html

 

In the configuration part, I ask plugin to copy the services.xml (the same as the preceding one) into .aar file’s META-INF directory.

 

All you need to do next is copy the .arr file into the Axis2 service directory. Simple?

Advertisements
This entry was posted in Web Service. Bookmark the permalink.

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