KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > ws_rm > client > Client


1 package demo.ws_rm.client;
2
3 import java.io.File JavaDoc;
4 import java.lang.reflect.UndeclaredThrowableException JavaDoc;
5 import javax.xml.namespace.QName JavaDoc;
6
7 import org.objectweb.hello_world_soap_http.Greeter;
8 import org.objectweb.hello_world_soap_http.SOAPService;
9
10
11 public final class Client {
12     
13     private static final QName JavaDoc SERVICE_NAME =
14         new QName JavaDoc("http://objectweb.org/hello_world_soap_http", "SOAPService");
15     private static final String JavaDoc USER_NAME = System.getProperty("user.name");
16
17
18     private Client() {
19     }
20
21     public static void main(String JavaDoc args[]) throws Exception JavaDoc {
22         if (args.length == 0) {
23             System.out.println("please specify wsdl");
24             System.exit(1);
25         }
26         
27         try {
28             File JavaDoc wsdl = new File JavaDoc(args[0]);
29             SOAPService service = new SOAPService(wsdl.toURL(), SERVICE_NAME);
30             Greeter port = service.getSoapPort();
31
32             // make a sequence of 8 invocations
33
for (int i = 0; i < 4; i++) {
34                 System.out.println("Invoking sayHi...");
35                 String JavaDoc resp = port.sayHi();
36                 System.out.println("Server responded with: " + resp + "\n");
37
38                 System.out.println("Invoking greetMeOneWay...");
39                 port.greetMeOneWay(USER_NAME);
40                 System.out.println("No response as method is OneWay\n");
41             }
42
43             // allow aynchronous resends to occur
44
Thread.sleep(30 * 1000);
45         } catch (UndeclaredThrowableException JavaDoc ex) {
46             ex.getUndeclaredThrowable().printStackTrace();
47         } catch (Exception JavaDoc ex) {
48             ex.printStackTrace();
49         } finally {
50             System.exit(0);
51         }
52     }
53 }
54
Popular Tags