package samples.userguide.example2 ; 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; import org.apache.wsil.*; import org.apache.wsil.client.*; import org.apache.wsil.util.*; import java.util.*; import javax.wsdl.*; public class CalcClient1 { public static void main(String [] args) throws Exception { Options options = new Options(args); /* String endpoint = "http://localhost:" + options.getPort() + "/axis/Calculator.jws"; */ // Location of the WS-Inspection document String wsinspectionURL = "file:///u/purshah/CGL/Part2/WSIL/Ex1.wsil"; String serviceName = "Calculator"; // Create a new instance of a WS-Inspection document proxy WSILProxy proxy = new WSILProxy(wsinspectionURL); // Get all of the WSDL documents using the input service name WSDLDocument[] wsdlDocuments = proxy.getWSDLDocumentByServiceName(serviceName); // Get definition element from first WSDL document Definition definition = wsdlDocuments[0].getDefinitions(); // Get the target Namespace of this definition element String endpoint = definition.getTargetNamespace(); args = options.getRemainingArgs(); if (args == null || args.length != 3) { System.err.println("Usage: CalcClient arg1 arg2"); return; } String method = args[0]; if (!(method.equals("add") || method.equals("subtract"))) { System.err.println("Usage: CalcClient arg1 arg2"); return; } Integer i1 = new Integer(args[1]); Integer i2 = new Integer(args[2]); Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress( new java.net.URL(endpoint) ); call.setOperationName( method ); call.addParameter( "op1", XMLType.XSD_INT, ParameterMode.IN ); call.addParameter( "op2", XMLType.XSD_INT, ParameterMode.IN ); call.setReturnType( XMLType.XSD_INT ); Integer ret = (Integer) call.invoke( new Object [] { i1, i2 }); System.out.println("Got result : " + ret); } }