01: package samples.transport;
02:
03: import org.apache.axis.client.Call;
04: import org.apache.axis.client.Service;
05: import org.apache.axis.configuration.XMLStringProvider;
06: import org.apache.axis.deployment.wsdd.WSDDConstants;
07: import org.apache.axis.encoding.XMLType;
08: import org.apache.axis.utils.Options;
09:
10: import javax.xml.namespace.QName;
11: import javax.xml.rpc.ParameterMode;
12:
13: /** Tests the simple File transport. To run:
14: * java org.apache.axis.utils.Admin client client_deploy.xml
15: * java org.apache.axis.utils.Admin server deploy.xml
16: * java samples.transport.FileTest IBM
17: * java samples.transport.FileTest XXX
18: */
19:
20: public class FileTest {
21: static final String wsdd = "<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" "
22: + "xmlns:java=\""
23: + WSDDConstants.URI_WSDD_JAVA
24: + "\">\n"
25: + " <transport name=\"FileTransport\" pivot=\"java:samples.transport.FileSender\"/>\n"
26: + " <service name=\""
27: + WSDDConstants.URI_WSDD
28: + "\" provider=\"java:MSG\">\n"
29: + " <parameter name=\"allowedMethods\" value=\"AdminService\"/>\n"
30: + " <parameter name=\"className\" value=\"org.apache.axis.utils.Admin\"/>\n"
31: + " </service>\n" + "</deployment>";
32:
33: public static void main(String args[]) throws Exception {
34: FileReader reader = new FileReader();
35: reader.setDaemon(true);
36: reader.start();
37:
38: Options opts = new Options(args);
39:
40: args = opts.getRemainingArgs();
41:
42: if (args == null) {
43: System.err.println("Usage: GetQuote <symbol>");
44: System.exit(1);
45: }
46:
47: String symbol = args[0];
48: Service service = new Service(new XMLStringProvider(wsdd));
49: Call call = (Call) service.createCall();
50:
51: call.setOperationName(new QName("urn:xmltoday-delayed-quotes",
52: "getQuote"));
53: call.addParameter("symbol", XMLType.XSD_STRING,
54: ParameterMode.IN);
55: call.setReturnType(XMLType.XSD_FLOAT);
56: call.setTransport(new FileTransport());
57: call.setUsername(opts.getUser());
58: call.setPassword(opts.getPassword());
59: call.setTimeout(new Integer(10000));
60:
61: Float res = new Float(0.0F);
62: res = (Float) call.invoke(new Object[] { symbol });
63:
64: System.out.println(symbol + ": " + res);
65:
66: reader.halt();
67: }
68: }
|