01: /*
02: * Copyright 2001-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
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: /**
29: * This version of GetInfo is a near-duplicate of the GetInfo class in
30: * samples/stock. This version is strictly JAX-RPC compliant. It uses
31: * no AXIS enhancements.
32: *
33: * @author Russell Butek (butek@us.ibm.com)
34: */
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(
49: null);
50: Call call = service.createCall();
51:
52: call.setTargetEndpointAddress(opts.getURL());
53: call.setOperationName(new QName("urn:cominfo", "getInfo"));
54: call.addParameter("symbol", XMLType.XSD_STRING,
55: ParameterMode.IN);
56: call.addParameter("info", XMLType.XSD_STRING, ParameterMode.IN);
57: call.setReturnType(XMLType.XSD_STRING);
58: if (opts.getUser() != null)
59: call.setProperty(Call.USERNAME_PROPERTY, opts.getUser());
60: if (opts.getPassword() != null)
61: call
62: .setProperty(Call.PASSWORD_PROPERTY, opts
63: .getPassword());
64:
65: String res = (String) call.invoke(new Object[] { args[0],
66: args[1] });
67:
68: System.out.println(symbol + ": " + res);
69: } // main
70: }
|