Eclipse WTP Tutorials - Creating Top Down Web Service via Apache Axis2

By Lahiru Sandakith
WSO2 Inc.
June 29, 2007


This tutorial is meant to demonstrate the use of the newly introduced Axis2 Web Services tools in the Web Tools Platform Project using the WTP 2.0 drivers. Also this tutorial shows how to create a simple top-down Web service from a WSDL file and test that with the WSE (Web Service Explorer). The WSDL file in this scenario calculates the area of an rectangle and its the same WSDL that used in the Axis web services tutorials.

Set Up
  Before creating the Web service, there are two prerequisites:
  1. Install Latest Eclipse WTP 2.0 integration driver
  2. Configure Apache Tomcat inside Eclipse WTP
Creating a top down Java bean Web service and Web service client using Axis2 WTP Tools

This tutorial need a Axis2 runtime. You can download the latest axis2 binary distribution from here .
Note : Currently Axis2 version 1.2 is the supported version for the Web Services Scenarios.

  1. Download the latest Axis2 runtime from the above link and extract it.

  2. Now we point Eclipse WTP to downloaded Axis2 Runtime. Open Window -> Preferences -> Web Services -> Axis2 Emitter

  3. Select the Axis2 Runtime tab and point to the correct Axis2 runtime location. Alternatively at the Axis2 Preference tab you can set the default setting that will come up on the Web Services Creation wizards. For the moment we will accept the default settings.

  4. Click OK.

  5. Next we need to create a project with the support of Axis2 features. Open File -> New -> Other... -> Web -> Dynamic Web Project

  6. Click next

  7. Select the name Axis2WSTest as the Dynamic web project name(You can specify any name you prefer), and select the configured tomcat runtime as the target runtime

  8. Click next

  9. Select the Axis2 Project Facet

  10. Click next

  11. Select the Axis2 Project Facet

  12. Click Finish

  13. This will create a dynamic web project in the workbench

  14. Create a folder called WSDL on the Axis2WSTest project. Import the file AreaService.wsdl into Axis2WSTest/wsdl.

  15. Build the Project, if its not auto build.

  16. Now we are going to invoke the web service creation wizard with respect to the newly imported WSDL. By selecting AreaService.wsdl source the Open File -> New -> Other... -> Web Services -> Web Service

  17. Click next

  18. Because of the wizard was invoked related to a correct WSDL the correct web services scenario will be picked automatically with the correct service definition. Also the configuration must be automatically set to the correct server, web service runtime and the service project. Make sure that you have selected the scale until to the start service. Also make sure you have the exact same items for the Server, Web Service Runtime and Service Project. Else make appropriate changes to select them as displayed below.

  19. Click next

  20. This page is the skeleton JAVA bean configuration page. if you have a custom preferences you can edit the configuration as needed, for the moment default will do.

  21. Click next

  22. This page is the start server page. Click on the start server. This will start the server runtime.

  23. Click next

  24. This page is the web services publication page, accept the defaults.

  25. Click Finish. You will see the newly created skeleton page gets pop up in the Editor. If you need you can edit the skeleton to include your area service logic. But for the moment We will accept the defaults settings.

  26. Here after the skeleton generation the user need to fill the nessesary parts of the service skeleton with the bussiness logic. In this example the CalculatedRectArea method TODO plus the exception must be replace with appropriate logic. For that we need some changes in the build system to auto reflect the change in the deployed service. One thing is we need to make sure that Build Automatically is enabled in the Project Menu. Then we need to change the output location of the project to the location where the service is deployed in the local web service runtime attached to the project. As in this example to the folder WebContent -> axi2-web -> WEB-INF -> services -> Axis2TestWs directory.

  27. So now we have done the nessesary thing to auto deploy our TD created web service. Now we go ahead and implement the skeleton. Replave the TODO plus the exception with the following logic foe calculating the Area.
    org.tempuri.areaservice.Area area = new org.tempuri.areaservice.Area(); area.setArea( parameters.getParameters().getHeight() * parameters.getParameters().getWidth(); return area;

  28. Tigger a auto build after saving. You will notice in the console that the service getting re deployed in the server.

  29. Now we can run the Dynamic Web Project on the server to see our top down created web service running on axis2 server. For that Select the Axis2WSTest dynamic web project and select Run -> Run As -> Run on Server

  30. Click Next.

  31. Make sure you have the Axis2WSTest dynamic web project on the Configured project.

  32. Click Next.

  33. This page is the web services publication page, accept the defaults.

  34. Click Finish.

  35. By doing the above test the Axis2 server webapp will be automatically deployed on the configured servlet container and will display the axis2 home page.

  36. By selecting services can view the available services. The newly created AreaService will be available there.

  37. If you need to test the newly creating AreaService with the WSE. at the first page of the skeleton scenario you can increase the slider to the test lever so that the created service can be tested against the Web Services Explorer.

  38. So after the normal pagers it will add another additional page to select the test facility. Select the Web Service Explorer

  39. Now For testing of the newly created AreaService with the WSE, at the end of the scenario it will launch the Web Services Explorer with the nessesary configuration loaded so that user can invoke the service easily.

  40. Please refer the Using Web Service Explorer to test a Web service for more details.


The Web Service wizard is orchestrating the end-to-end generation, assembly, deployment, installation and execution of the Web service, Web service client. In this scenario, we completed the top-down web service creation scenario using WTP web services tools. Most of the time the wizard will pick reasonable defaults according to the basic high-level choices. After completing this scenario, the WSDL for the AreaService Web service can be found in Clicking on the available services converter service link Now that your Web service is running, there are a few interesting things you can do with this WSDL file. Examples:

  • You can choose Web Services -> Test with Web Services Explorer to test the service.
  • You can choose Web Services -> Publish WSDL file to publish the service to a public UDDI registry.
  • You choose New -> Other... -> Web Services -> Web Service Client to generate a Web service client.


You can also refer the Axis web services creation wizards.