advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

Tutorials : Using Apache Axis version 1 to build Web Services :

Using the Axis utilities

Axis also comes with a set of very useful stand alone Java utilities. Since they are not run from the server you must be careful to set up the proper classpath before executing them. On my Win98 computer I’ve found it useful to write a small bat-file that does this for you:

@echo off
set AXISROOT=d:\apache\jakarta-tomcat-4.0.1\webapps\axis\web-inf\lib\
set TOMCATROOT=d:\apache\jakarta-tomcat-4.0.1\

set CP=.
set CP=%CP%;%AXISROOT%axis.jar
set CP=%CP%;%AXISROOT%axis-ant.jar
set CP=%CP%;%AXISROOT%commons-discovery.jar
set CP=%CP%;%AXISROOT%commons-logging.jar
set CP=%CP%;%AXISROOT%jaxrpc.jar
set CP=%CP%;%AXISROOT%log4j-1.2.4.jar
set CP=%CP%;%AXISROOT%saaj.jar
set CP=%CP%;%AXISROOT%wsdl4j.jar
set CP=%CP%;%TOMCATROOT%common\lib\servlet.jar
rem Remove the next if jdk1.4 is used
set CP=%CP%;%TOMCATROOT%common\lib\xerces.jar
set CLASSPATH=%CP%

Figure 1: The setcp bat file

The first line shows the directory where my Axis jar files are located. The next line is where Tomcat is installed. To ease debugging of my bat-file I add one jar file per line. I’ve included all the jar-files from the Axis installation, and also the servlet jar, which you may find in the Tomcat common/lib directory. You also need an XML parser if you’re running a JDK prior to 1.4.

You of course have the option to add the jar files to your global classpath, but I personally prefer to start out with a clean classpath whenever I run a Java program.

We’ll need three of the Axis utilities when we build and test the application:

The AdminClient utility
This utility is used to deploy, undeploy and list your web services. Again we make a small bat-file for easy execution:

java org.apache.axis.client.AdminClient %1

Figure 2: The adminclient bat file

The tcpmon utility
This utility is used to monitor the HTTP communication between the client and the server

java org.apache.axis.utils.tcpmon %1 %2 %3 

Figure 3: The tcpmon bat file

I’ve found it most convenient to place these files in the WEB-INF folder, together with the deployment files.

When we begin building our application we’ll start using these utilities.

The DVD application

Once more I’ll take out my good old DVD application, which I recently used in two articles entitled "Struts meets Swing (1)" and "Struts meets Swing (2)". The business case is to make an application that can be used to maintain a collection of DVDs. You should be able to list all DVDs, update and delete a DVD, create a new DVD, and of course save the collection on persistent storage (implemented through an XML file). The Swing look is this:

 

To make a new application based on web service technology (and with exactly the same GUI) we’ll need the following web services:

  • return list of DVD titles (to populate the combo box)
  • return details for one DVD (to fill the 4 text fields)
  • update a DVD
  • create a DVD
  • delete a DVD
  • save all the DVDs

We’d of course like to use as much of the code from the Struts application as possible, so let me sketch the architecture of the application:

The DVDManager is a Java class that handles all the operations on the DVD collection. It implements the following main actions:

  • read (and keep) DVD data from XML file
  • return titles for DVDs
  • return details for one DVD
  • update a DVD
  • create a DVD
  • delete a DVD
  • save all DVDs

It’s therefore easy to match the web service requests to the actions in the DVDManager.

The DVDManager acts as a buffer to the XML file, and it keeps all the DVD information in memory and only saves it to the XML file when the user requests so. The architecture is therefore "single-user", but could easily be changed to a "multi-user" architecture working on a data base instead. Since the focus in this article is on web service technology we can live with this simplified back-end architecture.

The Swing client only holds the titles of the DVDs, and to simplify the example they’re held in a list structure matching the one in the DVDManager. This means that element number 3 in one list is also number 3 in the other list. A more realistic solution would probably be to use a unique key for every DVD for lookup in the DVDManager.

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 Microsoft Visual Studio 2010 Showcase
 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 39
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

Windows 7: From Beta to Final Code in One Year
Google Shows Off Chrome OS, Releases Source
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?
Fedora 12 Takes Aim at Linux Networking
Top Supercomputer Nearly Doubles in Speed
Fedora 12 Linux Tackles Virtualization
Apple Gives iPhone Developers App Status Tracker
Novell Sets OpenSUSE 11.2 Free

Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Exploring HTML 5's Audio/Video Multimedia Support
Overriding Virtual Functions? Use C++0x Attributes to Avoid Bugs.
Understanding the Cloud Computing Security Vulnerabilities
Cisco and IBM Target a Greener World
Upgrade to Visual Studio 2010 with the Ultimate Offer

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs