This tutorial is intended for Java developers who are looking forward for developing their first SOAP based Axis2 Web Service
application. Theoretical knowledge of Web Services (including SOAP
& WSDL) and practical knowledge of Eclipse IDE , ANT will be a
prerequisite for understanding this tutorial.
Tools required :
Java 7 (JDK & JRE), Eclipse 3.5, Axis2 1.5
I will be using Axis2, which is one of the widely used web
service/SOAP engine for deploying the below created sample web service
component. I assume you already have Java & Eclipse installed in
your system.Steps for creating & running your first SOAP based Axis2 Web Service
1. Install Axis2 :
The latest version of Axis2 can be downloaded from here.
Its available for download in two different formats – Standard &
WAR distributions. I will be making use of the Standard binary
distribution in this example. However, WAR distribution can be used
instead, if you want to embed the Axis2 engine in a servlet container
like Tomcat.
After downloading Axis2, to complete the installation, ‘AXIS2_HOME‘ environment variable needs to be pointed to the Axis2 home directory(eg., C:/Axis2-1.5).
2. Create a new Java project :
Create a new Java project titled ‘SampleWS’ inside your Eclipse. Create a new java class called ‘SampleService‘ inside the ‘com.techsagar.ws’ package. Add the below code as part of this class.
We will be exposing the ‘getOSName()’ method which is returning the name of the operating system, as a web service.
3. Configure the web service methods :
Create a new ‘services.xml’ file in the project path & add the following contents,
4. Package & deploy the component :
Create a new build.xml in the project path & add the following ant script to package the web service component.
5. Start the Axis2 Runtime :
Axis2 service can be started by running
the ‘axis2server.bat’ present within the ‘%AXIS2_HOME%/bin’ directory.
Thats it, your Axis2 Web Service will be up & running. You can
access the Axis2 Web Service end point (WSDL) by pointing your browser
to the ‘http://localhost:8080/axis2/services/SampleService?wsdl‘ URL. The Axis2 Web Service methods can be tested by creating a proxy of the service using a language of your choice.