Axis 2 - Part 2: Installation and first use

December 2016




Implementation

  • Axis requires an application server such as Tomcat or more precisely a servlet container. So the first step is to install the application server on which the web services will be deployed.
  • To launch Axis, we will use the standard binary distribution provided by the Apache Software Foundation.
  • So just unpack the compressed file ( axis2-1.4-bin.zip) to find all you need to launch Axis.
  • Axis can be started in standolone mode this through the file $AXIS2_HOME\bin\axis2server.bat
  • After launching Axis, you can see the list of services available in standalone mode through the following URL: http://localhost:8080/axis2/services/.
  • To use Axis with an application server just follow the following steps:
    • Unzip the distribution of Axis 2 from the axis2-1.4-bin.zip.
    • Open the command prompt and type cd $AXIS2_HOME\axis2-1.4\webapp
    • Install Ant 1.6.5 or later.
    • Run the build.xml file with Ant.
    • The Axis2.war file is generated under the /dist directory.

Place the axis2.war file in the webapps directory and restart the server.
Axis is a web application deployed under Tomcat. The axis2.war file contains alllib necessary for the creation and deployment of web services. The structure of axis2.war looks like this:

axis2-web 
META-INF
WEB-INF
    classes 
    conf
        axis2.xml 
    lib
        activation.jar
        ...
        xmlSchema.jar
    modules
        modules.list 
        addressing.mar
        ...
        soapmonitor.mar
    services
        services.list
        aservice.aar
        ...
        version.aar
    web.xml


You can view the main page of the Axis application can be accessed here: [ http://localhost:8080/axis2/]


To see the list of deployed services click on Services.


The Validate link will verify that all the required libraries by Axis, are present in the application.

Deploying Web Services


The Axis2 web services can be deployed as a *.aar files. The structute of a service is a follows:
- CataloguePrix
   - META-INF
     - services.xml
   - lib
   - com
     - owliance
       - console
         - parametrage
           - CataloguePrix.class


CataloguePrix refers to the service name, the same name must be indicated in the services.xml file. Classes are placed directly at the root, along with their packages. And the lib directory contains the *.jar necessary to run the services. The services.xml file defines the service and it matches it with the appropriate Java class.

Creation of web service


The prototype of the next project shows how to create a web service. It is an eclipse project with the following structure:

The class associated with the web service can check the price of a product and update it.
In this project named as OwlianceWS, a build.xml file exist in order to build the project through the ANT utility.

Build.xml contains:
  • a compile.service target for compilation,
  • a generate.wsdl target to create the wsdl description associated with the web servcie
  • a generate.service target that allows encapsulation of the Web service into a archive with the .aar extension.

To deploy the service simply place the .aar file in the following directory: "Webservices $TomeCat\ webapps\axis2\WEB-INF\services" and restart the application server.
To test the service simply call the URL http://localhost:8080/axis2/services/CataloguePrix/getPrice?symbol=OWLT..
The result obtained is then:

Related :

This document entitled « Axis 2 - Part 2: Installation and first use » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.