KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > samples > transport > FileTest


1 package samples.transport ;
2
3 import org.apache.axis.client.Call;
4 import org.apache.axis.client.Service;
5 import org.apache.axis.configuration.XMLStringProvider;
6 import org.apache.axis.deployment.wsdd.WSDDConstants;
7 import org.apache.axis.encoding.XMLType;
8 import org.apache.axis.utils.Options;
9
10 import javax.xml.namespace.QName JavaDoc;
11 import javax.xml.rpc.ParameterMode JavaDoc;
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 JavaDoc wsdd =
22             "<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" " +
23                   "xmlns:java=\"" + WSDDConstants.URI_WSDD_JAVA + "\">\n" +
24             " <transport name=\"FileTransport\" pivot=\"java:samples.transport.FileSender\"/>\n" +
25             " <service name=\"" + WSDDConstants.URI_WSDD + "\" provider=\"java:MSG\">\n" +
26             " <parameter name=\"allowedMethods\" value=\"AdminService\"/>\n" +
27             " <parameter name=\"className\" value=\"org.apache.axis.utils.Admin\"/>\n" +
28             " </service>\n" +
29             "</deployment>";
30
31     public static void main(String JavaDoc args[]) throws Exception JavaDoc {
32         FileReader reader = new FileReader();
33         reader.setDaemon(true);
34         reader.start();
35
36         Options opts = new Options( args );
37
38         args = opts.getRemainingArgs();
39
40         if ( args == null ) {
41             System.err.println( "Usage: GetQuote <symbol>" );
42             System.exit(1);
43         }
44
45         String JavaDoc symbol = args[0] ;
46         Service service = new Service(new XMLStringProvider(wsdd));
47         Call call = (Call) service.createCall();
48
49         call.setOperationName( new QName JavaDoc("urn:xmltoday-delayed-quotes", "getQuote") );
50         call.addParameter( "symbol", XMLType.XSD_STRING, ParameterMode.IN );
51         call.setReturnType( XMLType.XSD_FLOAT );
52         call.setTransport( new FileTransport() );
53         call.setUsername(opts.getUser() );
54         call.setPassword(opts.getPassword() );
55         call.setTimeout(new Integer JavaDoc(10000));
56
57         Float JavaDoc res = new Float JavaDoc(0.0F);
58         res = (Float JavaDoc) call.invoke( new Object JavaDoc[] {symbol} );
59
60         System.out.println( symbol + ": " + res );
61
62         reader.halt();
63     }
64 }
65
Popular Tags