Apache Axis Sample Code

Simple console application demonstrating how to execute a Web service using Java proxy classes generated with Apache Axis.

package com.attachmate.test;

//These classes were generated with the Apache Axis WSDL2Java utility
import localhost.TestServiceBean;
import localhost.TestServiceBeanServiceLocator;
import Test.TaskInput.ScreenInputs;
import Test.TaskOutput.ScreenOutputs;

/**
 * A simple console application that demonstrates how to execute a web service
 * with Java proxy classes.  The proxies were generated with the Apache Axis
 * WSDL2Java utility:
 *
 * java -cp "axis.jar;axis-ant.jar;commons-discovery.jar;commons-logging.jar;
 * jaxrpc.jar;log4j-1.2.4.jar;saaj.jar;wsdl4j.jar;xerces.jar"
 * org.apache.axis.wsdl.WSDL2Java http://localhost:8080/axis/services/Test?wsdl
 *
 * The classes in this sample were generated for an Axis web service.  The
 * generated code may be slightly different for other web service platforms and
 * WSDL formats.
 *
 * @see org.apache.axis.wsdl.WSDL2Java
 */
public class WSDL2JavaWSClient
{
    /**
     * Application entry point.
     * @param args Command line arguments.  Not used.
     */
    public static void main(String[] args)
    {
        try
        {
            //Get an instance of the service
            TestServiceBean service = new TestServiceBeanServiceLocator().getTest();

            //Set the task inputs
            ScreenInputs inputs = new ScreenInputs();
            inputs.setInput("data");

            //Execute the task
            ScreenOutputs outputs = service.task(inputs);

            //Display the output
            System.out.println(outputs.getOutput());
        }
        catch (Exception xx)
        {
            xx.printStackTrace();
        }
    }
}
Related Topics
Bullet Using Tasks in Your Applications, Overview
Bullet Building Applications Using Apache Axis
  Attachmate