01: package demo.streams.client;
02:
03: import java.io.File;
04: import java.lang.reflect.UndeclaredThrowableException;
05: import javax.xml.namespace.QName;
06: import org.objectweb.hello_world_soap_http.Greeter;
07: import org.objectweb.hello_world_soap_http.HelloWorldService;
08: import org.objectweb.hello_world_soap_http.PingMeFault;
09:
10: public final class Client {
11:
12: private static final QName SERVICE_NAME = new QName(
13: "http://objectweb.org/hello_world_soap_http",
14: "HelloWorldService");
15:
16: private Client() {
17: }
18:
19: public static void main(String args[]) throws Exception {
20:
21: try {
22: if (args.length == 0) {
23: System.out.println("please specify wsdl");
24: System.exit(1);
25: }
26:
27: File wsdl = new File(args[0]);
28:
29: HelloWorldService ss = new HelloWorldService(wsdl.toURL(),
30: SERVICE_NAME);
31: Greeter port = ss.getSoapPort();
32: String resp;
33:
34: System.out.println("Invoking sayHi...");
35: resp = port.sayHi();
36: System.out.println("Server responded with: " + resp);
37: System.out.println();
38:
39: System.out.println("Invoking greetMe...");
40: resp = port.greetMe(System.getProperty("user.name"));
41: System.out.println("Server responded with: " + resp);
42: System.out.println();
43:
44: System.out.println("Invoking greetMeOneWay...");
45: port.greetMeOneWay(System.getProperty("user.name"));
46: System.out
47: .println("No response from server as method is OneWay");
48: System.out.println();
49:
50: try {
51: System.out
52: .println("Invoking pingMe, expecting exception...");
53: port.pingMe();
54: } catch (PingMeFault ex) {
55: System.out
56: .println("Expected exception: PingMeFault has occurred.");
57: System.out.println(ex.toString());
58: }
59: } catch (UndeclaredThrowableException ex) {
60: ex.getUndeclaredThrowable().printStackTrace();
61: } catch (Exception ex) {
62: ex.printStackTrace();
63: } finally {
64: System.exit(0);
65: }
66: }
67:
68: }
|