Axis2 startup tutorial

Download and unzip Axis2.

Set Axis2 classpath on Linux:

$ export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home
$ export AXIS2_HOME=/Users/matjaz/Documents/axis2-1.5.4
$ export AXIS2_LIB=$AXIS2_HOME/lib
$ export AXIS2_CLASSPATH=$AXIS2_LIB/activation-1.1.jar:$AXIS2_LIB/antlr-2.7.7.jar:$AXIS2_LIB/axiom-api-1.2.10.jar:$AXIS2_LIB/axiom-dom-1.2.10.jar:$AXIS2_LIB/axiom-impl-1.2.10.jar:$AXIS2_LIB/axis2-adb-1.5.4.jar:$AXIS2_LIB/axis2-adb-codegen-1.5.4.jar:$AXIS2_LIB/axis2-ant-plugin-1.5.4.jar:$AXIS2_LIB/axis2-clustering-1.5.4.jar:$AXIS2_LIB/axis2-codegen-1.5.4.jar:$AXIS2_LIB/axis2-corba-1.5.4.jar:$AXIS2_LIB/axis2-fastinfoset-1.5.4.jar:$AXIS2_LIB/axis2-java2wsdl-1.5.4.jar:$AXIS2_LIB/axis2-jaxbri-1.5.4.jar:$AXIS2_LIB/axis2-jaxws-1.5.4.jar:$AXIS2_LIB/axis2-jibx-1.5.4.jar:$AXIS2_LIB/axis2-json-1.5.4.jar:$AXIS2_LIB/axis2-kernel-1.5.4.jar:$AXIS2_LIB/axis2-metadata-1.5.4.jar:$AXIS2_LIB/axis2-mtompolicy-1.5.4.jar:$AXIS2_LIB/axis2-saaj-1.5.4.jar:$AXIS2_LIB/axis2-soapmonitor-servlet-1.5.4.jar:$AXIS2_LIB/axis2-spring-1.5.4.jar:$AXIS2_LIB/axis2-transport-http-1.5.4.jar:$AXIS2_LIB/axis2-transport-local-1.5.4.jar:$AXIS2_LIB/axis2-xmlbeans-1.5.4.jar:$AXIS2_LIB/bcel-5.1.jar:$AXIS2_LIB/commons-codec-1.3.jar:$AXIS2_LIB/commons-fileupload-1.2.jar:$AXIS2_LIB/commons-httpclient-3.1.jar:$AXIS2_LIB/commons-io-1.4.jar:$AXIS2_LIB/commons-logging-1.1.1.jar:$AXIS2_LIB/geronimo-annotation_1.0_spec-1.1.jar:$AXIS2_LIB/geronimo-jaxws_2.1_spec-1.0.jar:$AXIS2_LIB/geronimo-jta_1.1_spec-1.1.jar:$AXIS2_LIB/geronimo-saaj_1.3_spec-1.0.1.jar:$AXIS2_LIB/geronimo-stax-api_1.0_spec-1.0.1.jar:$AXIS2_LIB/geronimo-ws-metadata_2.0_spec-1.1.2.jar:$AXIS2_LIB/httpcore-4.0.jar:$AXIS2_LIB/jalopy-1.5rc3.jar:$AXIS2_LIB/jaxb-api-2.1.jar:$AXIS2_LIB/jaxb-impl-2.1.7.jar:$AXIS2_LIB/jaxb-xjc-2.1.7.jar:$AXIS2_LIB/jaxen-1.1.1.jar:$AXIS2_LIB/jettison-1.0-RC2.jar:$AXIS2_LIB/jibx-bind-1.2.1.jar:$AXIS2_LIB/jibx-run-1.2.1.jar:$AXIS2_LIB/juli-6.0.16.jar:$AXIS2_LIB/log4j-1.2.15.jar:$AXIS2_LIB/mail-1.4.jar:$AXIS2_LIB/mex-1.5.4-impl.jar:$AXIS2_LIB/neethi-2.0.4.jar:$AXIS2_LIB/regexp-1.2.jar:$AXIS2_LIB/tribes-6.0.16.jar:$AXIS2_LIB/woden-api-1.0M8.jar:$AXIS2_LIB/woden-impl-dom-1.0M8.jar:$AXIS2_LIB/wsdl4j-1.6.2.jar:$AXIS2_LIB/wstx-asl-3.2.9.jar:$AXIS2_LIB/xalan-2.7.0.jar:$AXIS2_LIB/xercesImpl-2.8.1.jar:$AXIS2_LIB/xml-resolver-1.2.jar:$AXIS2_LIB/xmlbeans-2.3.0.jar:$AXIS2_LIB/XmlSchema-1.4.3.jar

Example of POJO Web Service

SOAP over HTTPS

To enable HTTPS add this to the conf/axis2.xml:

<!-- Enable HTTPS -->
<transportReceiver name="https"
class="org.apache.axis2.transport.http.AxisServletListener">
<parameter name="port">8443</parameter>
</transportReceiver>

Axis2 web service directory structure:

HelloService
- META-INF
- - services.xml
- lib
- - zzzz.jar
- si
- - matjaz
- - - HelloService.class

Go to HelloService directory and generate .aar file. Classes should already be compiled.

$ jar cvf QuoteService.aar *

If you have prepared build.xml file you can compile classes and build .aar file with

$ ant generate.service

When service is deployed, wsdl file can be reached at:

http://localhost:8080/axis2/services/QuoteService?wsdl

If you get this error, Axis2 classpath is not set correctly:

java.lang.NoClassDefFoundError: org/apache/axiom/om/OMContainer

Generating service with ADB

This is known as ‘contract first’ approach. It means you should first define wsdl file and then generate server or client code according to the rules in wsdl.

$AXIS2_HOME/bin/wsdl2java.sh -uri QuoteService.wsdl -p si.matjaz -d adb -s -ss -sd -ssi -o build

Above operation will create build directory with the following directory structure:
- build
- - build.xml
- - resources
- - - QuoteService.wsdl
- - - services.xml
- src
- - si
- - - matjaz
- - - - zzzzz.java

Go inside build directory and run ant build.xml script with:

ant jar.server

If compiling and building was successful, you should see another build directory which contains compiled classes and lib directory with QuoteService.aar file.

Put QuoteService.aar file in

$TOMCAT6_HOME/webapps/axis2/WEB-INF/services

To see a list of all running services here:

http://localhost:8080/axis2/services/listServices