Creating a Web Service with Apache Axis
Filed in archive Web Services by jason on October 22, 2005
. We'll start with the idea that a web service client wants to retrieve a widget. The client will provide two parameters which will be the type of widget and the serial number of the widget. What will be returned to the client is a JavaBean that contains the contents of the widget requested. What I love about this example is the complete lack of XML parsing on the client side of this example. Axis takes care of the serialization of the bean on the server side and then the deserialization on the receiving side by adding the code the the bean for you upon deployment.First, download the latest Axis distribution from the Apache site. Deploy the sample "axis" web application, that is provided with the Axis distribution, to a servlet engine like Tomcat. Get the distribution to display the happyaxis.jsp without any errors by following the Axis documentation. After that is up and running you are ready to start playing around with your own web services.

It is at this point, and after a few hours of pain, that I break from the Apache documentation. They suggest that you use "java org.apache.axis.client.AdminClient" to deploy the service but I simply change the server-config.wsdd and redeploy the application as a *.war file. Below is an example of the entry I put in the WSDD file within the web application. Recreate the war file and redeploy to Tomcat or whatever servlet engine is being used.

After running WSDL2Java against the exposed WSDL of your web service you can now test your work. Below is a shot of the client I created to test my web service. Notice the fact that there is no need to parse any XML. The client simply gets back a JavaBean that contains the Widget.

Permalink: Creating a Web Service with Apache Axis
Tags:
Axis
web
Trackback: http://www.creative-weblogging.com/cgi-bin/mt-tb.pl/10496

Mr Wong
