This tutorial is meant to demonstrate the use of the introduced Axis2 Web Services tools in the Web Tools Platform Project using the WTP 2.0 and later 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:
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 versions 1.2, 1.3 and 1.4 are supported for the Web Services Scenarios.
Download the latest Axis2 runtime from the above link and extract it.
Now we point Eclipse WTP to downloaded Axis2 Runtime. Open Window -> Preferences -> Web Services -> Axis2 Preferences
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.
Click OK.
Next we need to create a project with the support of Axis2 features. Open File -> New -> Other... -> Web -> Dynamic Web Project
Click next
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
For WTP 3.0 or later If you are using WTP 2.0 click Next to setup axis2 project facet or if you are using WTP 3.0 or later click Modify button in the configuration to setup axis2 project facet.
For WTP 2.0 select the Axis2 Project Facet
Click Finish. For WTP 3.0 or later select the Axis2 Project Facet Click Ok and then click Finish.
This will create a dynamic web project in the workbench
Create a folder called WSDL on the Axis2WSTest project. Import the file File:AreaService wsdl.zip into Axis2WSTest/wsdl.
Build the Project, if its not auto build.
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
Click next
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.
Click next
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.
Click next
This page is the start server page. Click on the start server. This will start the server runtime.
Click next
This page is the web services publication page, accept the defaults (This page will not be present in WTP 3.0 and later).
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.
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 -> WEB-INF -> services -> Axis2TestWs directory.
So now we have done the nessesary thing to auto deploy our TD created web service. Now we go ahead and implement the skeleton. Replace the TODO plus the exception with the following logic foe calculating the Area.
org.tempuri.areaservice.Area area = new org.tempuri.areaservice.Area();
Trigger an auto build after saving. You will notice in the console that the service is getting re-deployed in the server.
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
Click Next.
Make sure you have the Axis2WSTest dynamic web project on the Configured project.
Click Next.
This page is the web services publication page, accept the defaults.
Click Finish.
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.
By selecting services can view the available services. The newly created AreaService will be available there.
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.
So after the normal pagers it will add another additional page to select the test facility. Select the Web Service Explorer
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.
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.
Resources
You can also refer the Axis web services creation wizards.