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