01: package demo.callback.client;
02:
03: import java.io.File;
04: import java.net.URL;
05:
06: import javax.xml.namespace.QName;
07: import javax.xml.ws.Endpoint;
08:
09: import org.objectweb.callback.SOAPService;
10: import org.objectweb.callback.ServerPortType;
11: import org.objectweb.celtix.Bus;
12: import org.objectweb.celtix.bus.wsdl.WSDLManagerImpl;
13: import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
14: import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
15:
16: public final class Client {
17:
18: private static final QName SERVICE_NAME = new QName(
19: "http://objectweb.org/callback", "SOAPService");
20:
21: private Client() {
22: }
23:
24: public static void main(String args[]) throws Exception {
25:
26: Bus bus = Bus.init();
27:
28: Object implementor = new CallbackImpl();
29: String address = "http://localhost:9005/CallbackContext/CallbackPort";
30: Endpoint.publish(address, implementor);
31:
32: if (args.length == 0) {
33: System.out.println("please specify wsdl");
34: System.exit(1);
35: }
36:
37: URL wsdlURL;
38: File wsdlFile = new File(args[0]);
39: if (wsdlFile.exists()) {
40: wsdlURL = wsdlFile.toURL();
41: } else {
42: wsdlURL = new URL(args[0]);
43: }
44:
45: SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
46: ServerPortType port = ss.getSOAPPort();
47:
48: EndpointReferenceType ref = EndpointReferenceUtils
49: .getEndpointReference(new WSDLManagerImpl(bus),
50: implementor);
51:
52: String resp = port.registerCallback(ref);
53:
54: System.out.println("Response from server: " + resp);
55:
56: bus.shutdown(true);
57:
58: System.exit(0);
59: }
60:
61: }
|