III Axis2 server implementation

Server skeleton generation

To generate the java skeleton for the axis server from the definition.wsdl file (Top down Java Web Service) :

  1. Create a new Dynamic Web Project called Axis2TutorialServer
  2. Right-click on the definition.wsdl file in the Eclipse Project Explorer view
  3. Choose : Web Services > Generate Java bean skeleton

Choose Install service in the top left spinner, and select :

  • the target Server (Tomcat)
  • the target Web service runtime (Axis2)
  • the Service project (Axis2TutorialServer)

Top down Axis2 Web Service

Click the Next button and select the custom mapping option. Select a target package for types in the namespace http://axis.tutorial/AxisTutorial :

Axis2 custom mapping definition

Click the Finish button. The server skeleton sources are generated under the axis.tutorial package of the Axis2TutorialServer Project :

Axis2TutorialServer project

Service implementation

You just need to implement the getById method in the Axis2TutorialSkeleton.java class to provide the desired service :

Axis2TutorialSkeleton.java

Download the full Axis2TutorialSkeleton.java file

Setting up the web application

Before you start the service provider, you must set up Axis to start and handle your web service at the application startup. The web.xml file under WebContent > WEB-INF tells Tomcat to map the Axis2 servlet to the /services URL. It means that every HTTP request made to an URL startig with /services will be handled by the Axis2 engine.

web.xml

The Axis2 engine use the services.xml files under WEB-INF/services/{service}/META-INF to deploy services. The services.xml of our listEmployeesService looks like :

ListEmployeesProvider project hierarchy

services.xml

You have nothing else to do, your service will automatically be available after the server startup. Our Axis2 web service server application is now finished. The implementation is quite simple and returns the requested CD.