01: package demo.hw_https.client;
02:
03: import java.io.File;
04: import java.net.URL;
05: import javax.xml.namespace.QName;
06: import org.objectweb.hello_world_soap_http.Greeter;
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 static final QName SECURE_PORT_NAME = new QName(
15: "http://objectweb.org/hello_world_soap_http", "SecurePort");
16:
17: private static final QName STRICT_SECURE_PORT_NAME = new QName(
18: "http://objectweb.org/hello_world_soap_http",
19: "StrictSecurePort");
20:
21: private static final QName INSECURE_PORT_NAME = new QName(
22: "http://objectweb.org/hello_world_soap_http",
23: "InsecurePort");
24:
25: private Client() {
26: }
27:
28: public static void main(String args[]) throws Exception {
29:
30: if (args.length == 0) {
31: System.out.println("please specify wsdl");
32: System.exit(1);
33: }
34:
35: URL wsdlURL;
36: File wsdlFile = new File(args[0]);
37: if (wsdlFile.exists()) {
38: wsdlURL = wsdlFile.toURL();
39: } else {
40: wsdlURL = new URL(args[0]);
41: }
42:
43: System.out.println(wsdlURL);
44: SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
45: Greeter port;
46:
47: if ((args[1] != null)
48: && (args[1].equalsIgnoreCase("secure_user"))) {
49: System.out
50: .println("The secure_user credentials will be used for the invocation.");
51: System.out.println();
52: port = ss.getPort(SECURE_PORT_NAME, Greeter.class);
53: } else if ((args[1] != null)
54: && (args[1].equalsIgnoreCase("strict_secure_user"))) {
55: String configurerProperty = "celtix.security.configurer"
56: + ".celtix.{http://objectweb.org/hello_world_soap_http}"
57: + "SOAPService/StrictSecurePort.http-client";
58: String configurerClass = "demo.hw_https.common.DemoSecurityConfigurer";
59: System.setProperty(configurerProperty, configurerClass);
60: System.out
61: .println("The strict_secure_user credentials will be used for the invocation.");
62: System.out
63: .println("Extra security data will be provided by the class, "
64: + configurerClass
65: + " because the system property "
66: + configurerProperty + " has been set.");
67: System.out.println();
68: port = ss.getPort(STRICT_SECURE_PORT_NAME, Greeter.class);
69: } else {
70: System.out
71: .println("The insecure_user credentials will be used for the invocation.");
72: System.out.println();
73: port = ss.getPort(INSECURE_PORT_NAME, Greeter.class);
74: }
75:
76: String resp;
77:
78: System.out.println("Invoking greetMe...");
79: try {
80: resp = port.greetMe(System.getProperty("user.name"));
81: System.out.println("Server responded with: " + resp);
82: System.out.println();
83:
84: } catch (Exception e) {
85: System.out
86: .println("Invocation to server failed with the following error : "
87: + e.getCause());
88: System.out.println();
89: }
90:
91: System.exit(0);
92: }
93:
94: }
|