This document will help you get up and running developing web services in Java using various tools. It's not really as hard as it seems. OK it can be, but only if you don't follow my advice. Despite what they tell you, you can do all of this on Windows (I used XP, I have no reason to suggest none of this wouldn't work on 2000). Note that a bunch of the paths for things are not necessarily the best place to put things, but represent what I could get to work. :-P
Install the following software:
Getting your environment set up is crucial for things to work. You will save yourself hours of pain if you check this carefully now. Note that you should not put trailing slashes on environment variables that are paths to directories.
|AXIS_HOME||This is where you put Axis, e.g. C:\Program Files\Apache Group\axis-1_1|
|AXIS_LIB||Axis' lib dir, set to %AXIS_HOME%\lib|
|AXISCLASSPATH||%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery.jar; %AXIS_LIB%\commons-logging.jar;%AXIS_LIB%\jaxrpc.jar; %AXIS_LIB%\saaj.jar;%AXIS_LIB%\log4j-1.2.8.jar; %AXIS_LIB%\wsdl4j.jar; %CATALINA_HOME%\webapps\axis\WEB-INF\lib\mysql-connector.jar|
|CATALINA_HOME||Where Tomcat Lives, e.g C:\Program Files\Apache Group\Tomcat 5.0|
|CLASSPATH||Java Class Path - %AXIS_HOME%;%CATALINA_HOME%\webapps\axis\WEB-INF\classes;%AXISCLASSPATH%;|
|JAVA_HOME||Where your Java 2 SDK lives - e.g. C:\Program Files\j2sdk1.4.2_04|
This script will automate most things, providing your environment is set up properly (see above). Place it in the same folder as your source files. It assumes you have a structure matching the package name over in %AXIS_HOME%, e.g. %AXIS_HOME%\org\mozilla\update\extensions for package org.mozilla.update.extensions. Invoke the script from a unix shell (use cygwin) like so: ./new_web_service.sh WebServiceClassName web.service.package.name - e.g. ./new_web_service.sh VersionCheck org.mozilla.update.extensions
I hope to come up with something better here but in the mean time read Getting Started using Web Services with Tomcat and AXIS - it has a Unix slant but pretty much everything applies.
A note when returning complex types - say you want to return a complex data type (equivalent to a C struct or C++ class) - you can't just use a Java class with a bunch of public fields on it since the Axis WSDL2Java generator transforms public fields into private ones and replaces them with accessor methods - which will cause your code not to compile if you're not careful. The solution is to define accessors on your complex data type yourself.
It can be difficult to test your service classes when they're being run on Tomcat and you have only your WSDL interface to deal with them through, and no easy way to see what's happening. Depending on the type of app you're writing, you might be able to include a static main() method on your classes to isolation test them using the java runtime from a console. The main method can test each of your APIs directly by instantiating the class, and each of the methods can use System.out.println()
Once you have Apache HTTPD and PHPMyAdmin set up, you should be able to browse to http://localhost/phpmyadmin/index.php (or wherever else you put it) and interact with databases. PHPMyAdmin is a pretty easy to use and flexible tool. Use it to create a database, set up some tables in it etc. You can also use it to test SQL queries directly before writing Java code that uses them - a nice easy way to test that what you're actually doing is right before you spend a lot of time debugging things.
To see how to use JDBC and Connector/J, see VersionCheck.java.
There is plenty of information online about SQL and how to use it, use Google.
Usually after you deploy a service using AdminClient and a wsdd file, you will have to reload the Axis extension to Tomcat.
Unlike Apache HTTPD, Tomcat's Windows app has no easy way to shut down or relaunch the service. I have not had much luck with its startup shell scripts and batch files, so I've found the only reliable way to get rid of it is to open Task Manager select the "tomcatw.exe" process and kill it (Alt+E), as well as killing the "java.exe" process.
(04/08/2004 - Ben Goodger)