01: package org.objectweb.hello_world_soap_http;
02:
03: import java.net.URL;
04:
05: import javax.xml.namespace.QName;
06:
07: import org.objectweb.celtix.Bus;
08:
09: public class GreeterClient {
10:
11: protected GreeterClient() {
12: }
13:
14: public static void main(String args[]) throws Exception {
15:
16: String operationName = "sayHi";
17: if (args.length > 0) {
18: operationName = args[0];
19: }
20: String[] params = null;
21: if (args.length > 1) {
22: params = new String[args.length - 1];
23: System.arraycopy(args, 1, params, 0, params.length);
24: }
25:
26: System.out.println("Invoking operation: " + operationName);
27: System.out.print("Parameters:");
28: for (String p : params) {
29: System.out.print(" " + p);
30: }
31: System.out.println();
32:
33: Bus bus = Bus.init();
34:
35: URL url = GreeterClient.class
36: .getResource("/wsdl/hello_world.wsdl");
37: assert null != url;
38:
39: QName serviceName = new QName(
40: "http://objectweb.org/hello_world_soap_http",
41: "SOAPService");
42: SOAPService ss = new SOAPService(url, serviceName);
43: Greeter port = ss.getSoapPort();
44:
45: if ("sayHi".equals(operationName)) {
46: System.out.println("Invoking sayHi...");
47: System.out
48: .println("server responded with: " + port.sayHi());
49: } else if ("greetMe".equals(operationName) && params != null
50: && params.length > 0) {
51: System.out.println("Invoking greetMe...");
52: System.out.println("server responded with: "
53: + port.greetMe(params[0]));
54: } else if ("greetMeOneWay".equals(operationName)
55: && params != null && params.length > 0) {
56: System.out.println("Invoking greetMeOneWay...");
57: port.greetMeOneWay(params[0]);
58: System.out
59: .println("no response from server as method is OneWay");
60: } else {
61: System.err.println("No such operation");
62: }
63:
64: bus.shutdown(true);
65: }
66:
67: }
|