KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > put


1 package test;
2
3 import org.apache.axis.Message;
4 import org.apache.axis.client.Call;
5 import org.apache.axis.client.Service;
6 import org.apache.axis.utils.Options;
7
8 import java.io.File JavaDoc;
9 import java.io.FileInputStream JavaDoc;
10
11 /**
12  * A convenient little test program which will send a message as is to
13  * the server. Useful for debugging interoperability problems or
14  * handling of ill-formed messages that are hard to reproduce programmatically.
15  *
16  * Accepts the standard options, followed by a list of files containing
17  * the contents to be sent.
18  */

19 class put {
20     static void main(String JavaDoc[] args) throws Exception JavaDoc {
21         Options opts = new Options(args);
22         String JavaDoc action = opts.isValueSet('a');
23
24         Service service = new Service();
25         Call call = (Call) service.createCall();
26
27         call.setTargetEndpointAddress( new java.net.URL JavaDoc(opts.getURL()) );
28         if (action != null ) {
29             call.setUseSOAPAction( true );
30             call.setSOAPActionURI( action );
31         }
32   
33         args = opts.getRemainingArgs();
34         for (int i=0; i<args.length; i++) {
35             FileInputStream JavaDoc stream = new FileInputStream JavaDoc(new File JavaDoc(args[i]));
36             call.setRequestMessage(new Message(stream));
37     
38             call.invoke();
39         
40             System.out.println(call.getResponseMessage().getSOAPPartAsString());
41         }
42     }
43 }
44
Popular Tags