01: package demo.callback.server;
02:
03: import java.net.URL;
04:
05: import javax.xml.namespace.QName;
06: import javax.xml.ws.Service;
07:
08: import org.objectweb.callback.CallbackPortType;
09: import org.objectweb.callback.ServerPortType;
10: import org.objectweb.celtix.Bus;
11: import org.objectweb.celtix.bus.wsdl.WSDLManagerImpl;
12: import org.objectweb.celtix.jaxb.JAXBUtils;
13: import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
14: import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
15: import org.objectweb.celtix.wsdl.WSDLManager;
16:
17: @javax.jws.WebService(name="ServerPortType ",serviceName="SOAPService",targetNamespace="http://objectweb.org/callback",wsdlLocation="file:./wsdl/basic_callback.wsdl")
18: public class ServerImpl implements ServerPortType {
19:
20: public String registerCallback(EndpointReferenceType callback) {
21:
22: try {
23: Bus bus = Bus.init();
24: WSDLManager manager = new WSDLManagerImpl(bus);
25:
26: QName interfaceName = EndpointReferenceUtils
27: .getInterfaceName(callback);
28: String wsdlLocation = EndpointReferenceUtils
29: .getWSDLLocation(callback);
30: QName serviceName = EndpointReferenceUtils
31: .getServiceName(callback);
32: String portString = EndpointReferenceUtils
33: .getPortName(callback);
34:
35: QName portName = new QName(serviceName.getNamespaceURI(),
36: portString);
37:
38: StringBuffer seiName = new StringBuffer();
39: seiName.append(JAXBUtils
40: .namespaceURIToPackage(interfaceName
41: .getNamespaceURI()));
42: seiName.append(".");
43: seiName.append(JAXBUtils
44: .nameToIdentifier(interfaceName.getLocalPart(),
45: JAXBUtils.IdentifierType.INTERFACE));
46:
47: Class<?> sei = null;
48: try {
49: sei = Class.forName(seiName.toString(), true, manager
50: .getClass().getClassLoader());
51: } catch (ClassNotFoundException ex) {
52: ex.printStackTrace();
53: }
54:
55: URL wsdlURL = new URL(wsdlLocation);
56:
57: Service service = Service.create(wsdlURL, serviceName);
58: CallbackPortType port = (CallbackPortType) service.getPort(
59: portName, sei);
60:
61: System.out.println("Invoking on callback object");
62: String resp = port.serverSayHi(System
63: .getProperty("user.name"));
64: System.out
65: .println("Response from callback object: " + resp);
66:
67: bus.shutdown(true);
68:
69: } catch (Exception ex) {
70: ex.printStackTrace();
71: return null;
72: }
73:
74: return "registerCallback called";
75: }
76:
77: }
|