1 16 17 package samples.userguide.example2 ; 18 19 import org.apache.axis.client.Call; 20 import org.apache.axis.client.Service; 21 import org.apache.axis.encoding.XMLType; 22 import org.apache.axis.utils.Options; 23 24 import javax.xml.rpc.ParameterMode ; 25 26 public class CalcClient 27 { 28 public static void main(String [] args) throws Exception { 29 Options options = new Options(args); 30 31 String endpoint = "http://localhost:" + options.getPort() + 32 "/axis/Calculator.jws"; 33 34 args = options.getRemainingArgs(); 35 36 if (args == null || args.length != 3) { 37 System.err.println("Usage: CalcClient <add|subtract> arg1 arg2"); 38 return; 39 } 40 41 String method = args[0]; 42 if (!(method.equals("add") || method.equals("subtract"))) { 43 System.err.println("Usage: CalcClient <add|subtract> arg1 arg2"); 44 return; 45 } 46 47 Integer i1 = new Integer (args[1]); 48 Integer i2 = new Integer (args[2]); 49 50 Service service = new Service(); 51 Call call = (Call) service.createCall(); 52 53 call.setTargetEndpointAddress( new java.net.URL (endpoint) ); 54 call.setOperationName( method ); 55 call.addParameter( "op1", XMLType.XSD_INT, ParameterMode.IN ); 56 call.addParameter( "op2", XMLType.XSD_INT, ParameterMode.IN ); 57 call.setReturnType( XMLType.XSD_INT ); 58 59 Integer ret = (Integer ) call.invoke( new Object [] { i1, i2 }); 60 61 System.out.println("Got result : " + ret); 62 } 63 } 64 | Popular Tags |