COMP534B Axis Tutorial
Getting Started with Axis and SOAP
The purpose of this tutorial is to allow you to become familiar with installing the Axis SOAP engine and writing, deploying and testing simple web services.
Installing the Axis software
1) Copy the Axis archive (axis-1_2_1.tar.gz) from /home/mhall/COMP534 to a directory in your home account.
2) Unpack the archive by typing tar xvfz axis-1_2_1.tar.gz. This will create a directory called axis-1_2_1.
3) Copy the jar files for the Xerces XML parser from /home/mhall/COMP534 to axis-1_2_1/lib.
Setting your CLASSPATH for running the Axis SOAP engine and programming for Axis
The Axis lib directory contains many jar files, all of which need to be in your CLASSPATH in order to run the Axis SimpleServer and for compiling Axis web services and client programs. The easiest thing to do is to create a file that you can ÒsourceÓ in order to set your CLASSPATH correctly each time you log in. Edit a file called axisClasspath and add the following lines to it:
AXIS_PATH=/home/<your username>/<path to axis>
CLASSPATH=.:$CLASSPATH:$AXIS_PATH/lib/xercesImpl.jar:$AXIS_PATH/lib/xml-apis.jar:$AXIS_PATH/lib/axis-ant.jar:É
export AXIS_PATH
export CLASSPATH
Replace the ÒÉÓ at the end of the second line with entries for EACH of the remaining jar files that are in the Axis lib directory. In order to set your CLASSPATH type
source axisClasspath
You can check that it worked by typing echo $CLASSPATH.
Check to see if the JAVA_HOME environment variable is defined for you. Type echo $JAVA_HOME. If this is not defined then you might want to add a couple of lines to your axisClasspath file in order to define it.
Assuming that you have set your CLASSPATH and are in the axis-1_2_1 directory, type
java org.apache.axis.transport.http.SimpleAxisServer –p 8080
This will start the SimpleAxisServer listening for connections on port 8080.
To bring the server down cleanly (assuming you have a second shell open and have set your CLASSPATH as described above) type:
java org.apache.axis.client.AdminClient quit
a) Compile the source:
1) Copy the helloaxis jar file from /home/mhall/COMP534 to a directory in your home account.
2) Unpack the helloaxis.jar file by typing jar xvf helloaxis.jar. This will create a directory called helloaxis.
3) Compile the source files. From the directory that contains the helloaxis directory type javac helloaxis/*.java.
b) Deploy the JWS version of HelloAxis
1) Copy the HelloAxis.jws file from the helloaxis directory to $AXIS_PATH/webapps/axis.
2) The SimpleAxisServer needs access to the java compiler in order to compile JWS web services on the fly. So, start the server as follows:
java –cp $JAVA_HOME/lib/tools.jar:$CLASSPATH \
org.apache.axis.transport.http.SimpleAxisServer –p 8080
3) From a separate terminal, in the directory that contains the helloaxis directory, run the client
java helloaxis.HelloAxisClient
If all goes well, you should see a message ÒAxis says hello to John.Ó
c) Deploy the standard version of HelloAxis
1) Stop the SimpleAxisServer (if it is running)
2) Make a jar file containing the HelloAxis classes to deploy on the server. From the directory containing the helloaxis directory type:
jar cvf helloAxisDeploy.jar helloaxis/Hello.class helloaxis/HelloAxis.class
3) Move the jar file to the Axis lib directory. Type mv helloAxisDeploy.jar $AXIS_PATH/lib
4) Start the server (making sure that Axis has access to the helloAxisDeploy.jar). Type
java –cp $AXIS_PATH/lib/helloAxisDeploy.jar:$CLASSPATH \
org.apache.axis.transport.SimpleAxisServer –p 8080
5) Assuming you have the SimpleAxisServer running, cd to the helloaxis directory and type
java org.apache.axis.client.AdminClient deploy.wsdd
You should see a message that says the deploy.wsdd is being processed and after a few seconds a second message that says that processing has finished.
6) Test the standard version using the client
a. First edit the HelloAxisClient.java file—comment out the line that sets the endpoint URL to HelloAxis.jws and uncomment the line that sets the endpoint URL to HelloAxis.
b. Compile the client.
c. Run the client. You should see the same message as before.
d) Use WSDL2Java to automatically generate client-side bindings
1) Create a directory called helloaxisClient.
2) While your SimpleAxisServer is running, use a web browser and browse to:
http://localhost:8080/axis/services/HelloAxis?wsdl
3) save the resulting XML WSDL to a file called helloaxis.wsdl in your helloaxisClient directory.
4) Create the client side bindings using the WSDL2Java utility. cd to the parent directory of helloaxisClient and type
java org.apache.axis.wsdl.WSDL2Java –o helloaxisClient \
helloaxisClient/helloaxis.wsdl
If all went correctly then you should see that a helloaxis directory has been created in the helloaxisClient directory that contains interface and stub files.
5) Write a test program that uses the generated client classes to access the web service (see the lecture notes).