Whole Network AJAX Basics conference E-Commerce Monthly Contest 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.






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

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

Related Entries:

Axis Goes a Long Way With Web Services - 13 October 2005

Pulling NOAA Data with Axis - 15 October 2005

5 Axis Scion xA 竞速者 - 24 November 2005

Rocketmen: Axis of Evil Isn't the Card Game - 07 May 2007





RSSrss   | See all blog subscribe options
Google google   |   What is RSS?
Yahoo! yahoo
Addthis Subscribe using any feed reader!
Bloglines Bloglines
Newsletter
Grouptivity

Use the search to look for other interesting posts



 
  • Advertise with us

  • Learn more about our advertising options or email advertising - at - creative-weblogging.com or give us a call at +1 (650) 331 4900.


  • Testimonials

  • 'Great looking blog. Good quality posts with useful information.'


  • Other blogs in the same channel in the Creative Weblogging Network







 

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