III Axis2 server implementation
Build a full web service with Axis2
Server skeleton generation
To generate the java skeleton for the axis server from the definition.wsdl file (Top down Java Web Service) :
- Create a new Dynamic Web Project called Axis2TutorialServer
- Right-click on the definition.wsdl file in the Eclipse Project Explorer view
- 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)
Click the Next button and select the custom mapping option. Select a target package for types in the namespace http://axis.tutorial/AxisTutorial :
Click the Finish button. The server skeleton sources are generated under the axis.tutorial package of the Axis2TutorialServer Project :
Service implementation
You just need to implement the getById method in the Axis2TutorialSkeleton.java class to provide the desired service :
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.
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 :
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.