1 16 17 package samples.jaxrpc; 18 19 import org.apache.axis.encoding.XMLType; 20 import org.apache.axis.utils.Options; 21 22 import javax.xml.namespace.QName ; 23 import javax.xml.rpc.Call ; 24 import javax.xml.rpc.ParameterMode ; 25 import javax.xml.rpc.Service ; 26 import javax.xml.rpc.ServiceFactory ; 27 28 35 public class GetInfo { 36 37 public static void main(String args[]) throws Exception { 38 Options opts = new Options(args); 39 40 args = opts.getRemainingArgs(); 41 42 if (args == null || args.length % 2 != 0) { 43 System.err.println("Usage: GetInfo <symbol> <datatype>"); 44 System.exit(1); 45 } 46 47 String symbol = args[0]; 48 Service service = ServiceFactory.newInstance().createService(null); 49 Call call = service.createCall(); 50 51 call.setTargetEndpointAddress(opts.getURL()); 52 call.setOperationName(new QName ("urn:cominfo", "getInfo")); 53 call.addParameter("symbol", XMLType.XSD_STRING, ParameterMode.IN); 54 call.addParameter("info", XMLType.XSD_STRING, ParameterMode.IN); 55 call.setReturnType(XMLType.XSD_STRING); 56 if(opts.getUser()!=null) 57 call.setProperty(Call.USERNAME_PROPERTY, opts.getUser()); 58 if(opts.getPassword()!=null) 59 call.setProperty(Call.PASSWORD_PROPERTY, opts.getPassword()); 60 61 String res = (String ) call.invoke(new Object [] {args[0], args[1]}); 62 63 System.out.println(symbol + ": " + res); 64 } } 66 67 | Popular Tags |