Whole Network Most Recent TOP10 AJAX E-Commerce Programming Security

 

Creating a Web Service with Apache Axis

Filed in archive Web Services by jason on October 22, 2005

What follows is a fairly high level explanation of how to create a web service with Apache axislinks. 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.

BlogPicture
Above is a very simple Widget Lookup service that I want to expose to the world through a web service. It contains a helloWorld method that I can use to test with later if I run into connectivity problems. There is also a simple method that takes two parameters and returns a JavaBean. Add your own simple service class to the axis sample application with supporting business logic and JavaBean that will be populated and returned.

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.

BlogPicture
The entry above exposes the two WidgetLookup methods (helloWorld(),widgetRecordLookup(type, serialNumber)) and the WSDL for the newly available web service can be see at http://localhost:8080/[you context path]/services/WidgetLookup?wsdl (the exact URL will depend on your environment). This WSDL is now important because it will allow you to create your own test client using the Axis utility WSDL2Java (I talked about this in an earlier entry here).

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.

BlogPicture
I realize that some of this is a bit over simplified but I'm trying to keep it short and sweet. If anyone has any questions leave me a comment or email me at java@creative-weblogging.com.


Advertisement


Permalink: Creating a Web Service with Apache Axis
Tags: Axis  web 

Trackback: http://www.creative-weblogging.com/cgi-bin/mt-tb.pl/10496



Advertisement


Advertisement


CW ToolbarInstall
RSSrss   | See all blog subscribe options
Googlegoogle   |   What is RSS?
Yahoo!yahoo
AddthisAddThis Feed Button
BloglinesBloglines
Newsletter
Advertisement - Book yours here.

Use our search feature to look for other interesting posts

Just this blog Whole network
Advertisement -
Book yours here..


 
Advertisement
Book yours here.



  • Testimonials

  • 'Great looking blog. Good quality posts with useful information.'
  • Other blogs in the same channel in the Creative Weblogging Network

Advertisement -
Book yours here..






Advertisement - Book yours here..
 
Tagcloud: AJAX Application Development Awards Basics Business conference E-Commerce Management Mobile Devices mobile phones Monthly Contest Personal Programming Security Service Oriented Architectures Sponsored Posts updates Web Services