01: package demo.ws_rm.client;
02:
03: import java.io.File;
04: import java.lang.reflect.UndeclaredThrowableException;
05: import javax.xml.namespace.QName;
06:
07: import org.objectweb.hello_world_soap_http.Greeter;
08: import org.objectweb.hello_world_soap_http.SOAPService;
09:
10: public final class Client {
11:
12: private static final QName SERVICE_NAME = new QName(
13: "http://objectweb.org/hello_world_soap_http", "SOAPService");
14: private static final String USER_NAME = System
15: .getProperty("user.name");
16:
17: private Client() {
18: }
19:
20: public static void main(String args[]) throws Exception {
21: if (args.length == 0) {
22: System.out.println("please specify wsdl");
23: System.exit(1);
24: }
25:
26: try {
27: File wsdl = new File(args[0]);
28: SOAPService service = new SOAPService(wsdl.toURL(),
29: 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 resp = port.sayHi();
36: System.out.println("Server responded with: " + resp
37: + "\n");
38:
39: System.out.println("Invoking greetMeOneWay...");
40: port.greetMeOneWay(USER_NAME);
41: System.out.println("No response as method is OneWay\n");
42: }
43:
44: // allow aynchronous resends to occur
45: Thread.sleep(30 * 1000);
46: } catch (UndeclaredThrowableException ex) {
47: ex.getUndeclaredThrowable().printStackTrace();
48: } catch (Exception ex) {
49: ex.printStackTrace();
50: } finally {
51: System.exit(0);
52: }
53: }
54: }
|