Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Creating a top-down Axis2 Web service

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

Wtplogosmall.png


By Lahiru Sandakith
WSO2 Inc.
June 29, 2007

Introduction


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:

  1. Install Latest Eclipse WTP 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 versions 1.2, 1.3 and 1.4 are supported 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 Preferences

    Ws buAxis2SetAxis2Pref.jpg
    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.
  3. Click OK.

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

    Ws buAxis2CreateDWP.jpg
    Click next
  5. 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

    Ws buAxis2CreateDWPnext.jpg

    For WTP 3.0 or later
    Ws buAxis2CreateDWPnext wtp 2.0.png
    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.
  6. For WTP 2.0 select the Axis2 Project Facet

    Ws buAxis2CreateDWPfacets.jpg
    Click Finish.
    For WTP 3.0 or later select the Axis2 Project Facet
    Ws buAxis2CreateDWPfacets wtp 3.0.png
    Click Ok and then click Finish.
  7. This will create a dynamic web project in the workbench

    Ws tdAxis2Workbench.png


  8. Create a folder called WSDL on the Axis2WSTest project. Import the file File:AreaService wsdl.zip into Axis2WSTest/wsdl.

    Ws tdAxis2WsdlFile.png
    Build the Project, if its not auto build.
  9. 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

    Ws buAxis2newWebService.png
    Click next
  10. 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.

    Ws tdAxis2WizardFirstPage.png
    Click next
  11. 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.

    Ws tdAxis2WizardConfigPage.png
    Click next
  12. This page is the start server page. Click on the start server. This will start the server runtime.

    Ws tdAxis2WizardStartServerPage.png
    Click next
  13. This page is the web services publication page, accept the defaults (This page will not be present in WTP 3.0 and later).

    Ws tdAxis2WizardPublishPage.png
    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.
  14. 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.

  15. 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();
        area.setArea( parameters.getParameters().getHeight() * parameters.getParameters().getWidth());
        return area;

    Ws tdAxis2WebServiceImplJavaFile.png

    Trigger an auto build after saving. You will notice in the console that the service is getting re-deployed in the server.
  16. 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

    Ws tdAxis2RunOnServer.png
    Click Next.
  17. Make sure you have the Axis2WSTest dynamic web project on the Configured project.

    Ws tdAxis2RunOnServer Addproject.png
    Click Next.
  18. This page is the web services publication page, accept the defaults.

    D3.png
    Click Finish.
  19. 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.

    Ws tdAxis2ServletPage.png

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

    Ws tdAxis2ServiceServletPage.png

  21. 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.

    Ws tdAxis2WebServiceWizard ScaleStart.png

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

    Wse 2.jpg

  23. 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.

    Ws tdAxis2WSE.png

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



Summary

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.

Contributors

Back to the top