topical media & game development

talk show tell print

professional-xml-19-Listing-19-11.txt / txt



  package com.wrox.webservices;
  
  import org.apache.axis.client.Call;
  import org.apache.axis.client.Service;
  import org.apache.axis.encoding.XMLType;
  import org.apache.axis.utils.Options;
  import javax.xml.rpc.ParameterMode;
  
  public class HelloWorldClient
  {
     public static void main(String [] args) throws Exception {
        Options options = new Options(args);
        String endpoint = "http://localhost:" + options.getPort() +
           "/axis/HelloWorld.jws";
        args = options.getRemainingArgs();
        if (args == null || args.length != 2) {
           System.err.println("Usage: HelloWorldClient <HelloWorld> arg1 ");
           return;
        }       
        String method = args[0];
        if (!(method.equals("HelloWorld"))){
           System.err.println("Usage: HelloWorld arg1 ");
            return;
        }
        String name = new String(args[1]); 
        Service  service = new Service();
        Call call  = (Call) service.createCall();
        call.setTargetEndpointAddress( new java.net.URL(endpoint) );
        call.setOperationName( method );
        call.addParameter( "name", XMLType.XSD_STRING, ParameterMode.IN );
        call.setReturnType( XMLType.XSD_STRING );
        String result = (String)call.invoke(new Object[] { name });
        System.out.println(result);
     }
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.