Installing and deploying web applications using xml-axis


Contents

Introduction

This document describes how to install Apache Axis. It assumes you already know how to write and run Java code and not be scare of XML. You should also have an application server or servlet engine and be familiar with operating and deploying to it. If you need an application server, we recommend Jakarta Tomcat. Other servlet engines are supported, provided they are version 2.2 or greater. Note also that Axis client and server requires Java1.3 or later.

For more details on using Axis, please see the user's guide.

Step 0: Concepts

Axis is implemented in the JAR file axis.jar; implementing the JAX-RPC API declared in the JAR files jaxrpc.jar and saaj.jar. It needs various helper libraries, for logging, WSDL processing and introspection. All these files can be packaged into a web application, axis.war, that can be dropped into a servlet container. Axis ships with some sample SOAP services. You can add your own by adding new compiled classes to the Axis webapp registering them.

Before you can do that, you have to install it and get it working.

Step 1: creating the webapps

In your servlet installation, you should find a directory into which web applications ("webapps") are to be placed. Into this directory copy the webapps/axis directory from the xml-axis distribution. You can actually name this directory anything you want, just be aware that the name you choose will form the basis for the URL by which clients will access your service. The rest of this document assumes that the default webapp name, "axis" has been used; rename these references if appropriate.

Step 2: setting up the libraries

In the axis directory, you will find a WEB-INF sub-directory. This directory contains some basic configuration information, but can also be used to contain the dependencies and web services you wish to deploy.

In the WEB-INF directory, you'll find a "lib" directory. 

Tomcat 4.x and Java1.4

Java 1.4 changed the rules as to to how packages beginning in java.* and javax.* get loaded. Specifically, they only get loaded from endorsed directories. jaxrpc.jar and saaj.jar contain javax packages, so may not get picked up. If happyaxis.jsp (see below) cannot find the relevant packages, place them in CATALINA_HOME/common/lib and restart Tomcat.

Step 3: starting the web server

This varies on a product-by-product basis. In many cases it it as simple as double clicking on a startup icon or running a command from the command line.

Step 4: Validate the Installation

After installing the web application and dependencies, you should make sure that the server is running the web application.

Look for the start page

Navigate to the start page of the webapp, usually http://127.0.0.1:8080/axis/, though of course the port may differ.
You should now see an Apache-Axis start page. If you do not, then the webapp is not actually installed, or the appserver is not running.

Validate Axis with happyaxis

Follow the link Validate the local installation's configuration
This will bring you to happyaxis.jsp a test page that verifies that needed and optional libraries are present. The URL for this will be something like http://localhost:8080/axis/happyaxis.jsp

If any of the needed libraries are missing, Axis will not work.
You must not proceed until all needed libraries can be found, and this validation page is happy.
Optional components are optional; install them as your need arises.

Look for some services

From the start page, select View the list of deployed Web services. This will list all registered Web Services, unless the servlet is configured not to do so. On this page, You should be able to click on (wsdl) for each deployed Web service to make sure that your web service is up and running.

Test a SOAP Endpoint

Now it's time to test a service. Although SOAP1.1 uses HTTP POST to submit an XML request to the endpoint, Axis also supports HTTP GET access, which is useful for testing. First let's retrieve the version of Axis from the version endpoint, calling the getVersion method: http://localhost:8080/axis/services/Version?method=getVersion This should return something like
  <?xml version="1.0" encoding="UTF-8" ?> 
  <soapenv:Envelope 
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
      <getVersionResponse 
          soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <getVersionReturn 
              xsi:type="xsd:string">
              Apache Axis version: 1.0 Built on Nov 04, 2002 (01:30:37 PST)
          </getVersionReturn> 
      </getVersionResponse>
      </soapenv:Body>
  </soapenv:Envelope>
The Axis version and build date will of course be different.

Test a JWS Endpoint

Now let's test a JWS web service. Axis' JWS Web Services are java files you save into the axis webapp anywhere but the WEB-INF tree, giving them the .java extension. When some requests the .jws file by giving its URL, it is compiled and executed. The user guide covers JWS pages in detail.

To test the JWS service, we make a request against a built in example, EchoHeaders.jws (look for this in the axis/ directory).

Point your browser at http://localhost:8080/axis/EchoHeaders.jws?method=list .

This should return an XML listing of your application headers, such as

<?xml version="1.0" encoding="UTF-8" ?> 
<soapenv:Envelope 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <listResponse 
            soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <listReturn xsi:type="soapenc:Array" 
                soapenc:arrayType="xsd:string[6]" 
                xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
                <item>accept:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*</item> 
                <item>accept-language:en-us</item> 
                <item>accept-encoding:gzip, deflate</item> 
                <item>user-agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)</item> 
                <item>host:localhost:8080</item> 
                <item>connection:Keep-Alive</item> 
            </listReturn>
        </listResponse>
    </soapenv:Body>
</soapenv:Envelope>

Again, the exact return values will be different, and you may need to change URLs to correct host, port and webapp specifics.

Step 5: installing new Web Services

So far you have got Axis installed and working, now it is time to add your own Web Service.

The process here boils down to (1) get the classes and libraries of this new service into the axis WAR directory tree, (2) tell the AxisEngine about the new file. The latter is done by submitting an XML deployment descriptor to the service via the Admin web service, which is usually done with the AdminClient program or the <axis-admin> Ant task

In the WEB-INF directory, look for (or create) a "classes" directory (i.e. axis/WEB-INF/classes ). In this directory, copy the compiled Java classes you wish to install, being careful to preserve the directory structure of the Java packages.

If your classes services are already packaged into JAR files, feel free to drop them into the WEB-INF/lib directory instead. Also add any third party libraries you depend on into the same directory.

After adding new classes or libraries to the Axis webapp, you must restart the webapp. This can be done by restarting your application server, or by using a server-specific mechanism to restart a specific webapp.

Note: If your web service uses the simple authorization handlers provided with xml-axis (this is actually not recommended as these are merely illustrations of how to write a handler than intended for production use), then you will need to copy the corresponding perms.lst and users.lst files into the WEB-INF directory.

Step 6: deploying your own web services

The various classes and JARs you have just set up implement your new Web Service. What remains to be done is to tell Axis how to expose this web service. Axis takes a Web Service Deployment Descriptor, (a WSDD file), that describes in XML what the service is, what methods it exports and other aspects of the SOAP endpoint.

The users guide covers these WSDD files; here we are going to use one from the Axis samples; the stock quote service.

The user's guide covers the AdminClient in more detail, and there is also an Ant task to automate its use in your build process.

Note: You may need to replace localhost with your host name, and 8080 with the port number used by your web server.If you have renamed the web application, something other than "axis" change the URL appropriately.

Step 7: testing

This step is optional, but highly recommended. For illustrative purposes, it is presumed that you have installed and deployed the stockquote demo.

Note: Again, you may need to replace localhost with your host name, and 8080 with the port number used by your web server. If you have renamed the web application, something other than "axis" change the URL appropriately.

Advanced Installation: adding Axis to your own Webapp

If you are experienced in webapp development, and especially if you want to add web services to an existing or complex webapp, you can take an alternate approach to running Axis. Instead of adding your classes to the axis webapp, you can add Axis to your application.

The core concepts are

  1. Add axis.jar, wsdl.jar, saaj.jar, jaxrpc.jar and the other dependent libraries to your WAR file.
  2. Copy all the Axis Servlet declarations and mappings from axis/WEB-INF/web.xml and add them to your own web.xml
  3. Build and deploy your webapp.
  4. Run the Axis AdminClient against your own webapp, instead of Axis, by changing the URL you invoke it with.
The process is also covered in covered in chapter 15 of Java Development with Ant, which can be downloaded as a PDF file.

Summary

Axis is simply an implementation of SOAP which can be added to your own webapp, and a webapp which can host your own web services. Installing it can be a bit fiddly, especially given Java1.4's stricter requirements. If you follow a methodical process, and test along the way, using happyaxis and the bundled test services, you will find it easier to get started with Axis.