urgent computing topline


Sample Web Service Clients

  $Revision: 1.3 $

This page lists some example clients written to access our UserServices Suite using different software packages.

Table of Contents

Java Client using Axis2

This document presents a simple guide to generating a Java WS client for the Spruce web services. It makes use of Apache Axis2 SOAP Stack. From the Axis2 installation, you need to include the following jar files in your class path:
  • axiom-api-1.0.jar
  • axiom-impl-1.0.jar
  • axis2-kernel-1.0.jar
  • neethi-1.0.1.jar
  • stax-api-1.0.jar
  • wstx-asl-2.9.3.jar

Below is the code from the actual client:

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;

public class UserPortalClient {
        // End-Point Reference
        private static EndpointReference targetEPR = new EndpointReference(

        public static void main(String[] args) {
              OMFactory fac = OMAbstractFactory.getOMFactory();
              OMNamespace omNs = fac.createOMNamespace
		("http://spruce.uchicago.edu/ws/xsd/", "spruce");

                 * test  checkTokenTime()
              OMElement method = fac.createOMElement("checkTokenTime", omNs);

                 * set token parameter -- needed for all method calls

              OMElement token = fac.createOMElement("token", omNs);
                token.addChild(fac.createOMText(token, "0000-0000-0000-0001"));
		 //expired token

              try {
                        Options options = new Options();

                        // Blocking invocation.
                        ServiceClient sender = new ServiceClient();
                        OMElement result = sender.sendReceive(method);


              } catch (AxisFault axisFault) {

The first step is to declare the endpoint reference (EPR). For the SPRUCE web services, this is currently http://spruce.uchicago.edu:8080/axis2/services/SpruceUserServices

Next, Axis2's Object Model (AXIOM) is used to generate the necessary XML for the call. This includes creating the parameter necessary for the call (in this case a 'token') and giving it a value. This parameter is attached as a child to an XML element that represents the method call (in this case, checkTokenTime()). Once the neccessary XML is created, the web service needs to be invoked. We use a Axis2's blocking invocation method, and print out the result. The execution produces the following results:

<spruce:SpruceFault xmlns:spruce="http://spruce.uchicago.edu/ws/xsd/ "
     <spruce:message>Token expired</spruce:message>
     <spruce:description>checkTokenTime::Token has expired</spruce:description>

This is the correct return in this case, as the method is being invoked on an expired token, which returns a spruce error message.


Contact Information

Please contact Spruce Team for any questions or problems using Spruce software.