01: package org.objectweb.celtix.systest.callback;
02:
03: import java.io.File;
04: import java.net.URL;
05:
06: import javax.xml.namespace.QName;
07: import javax.xml.ws.Service;
08:
09: import org.objectweb.callback.CallbackPortType; //import org.objectweb.callback.RegisterCallback;
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.jaxb.JAXBUtils;
14: import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
15: import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
16: import org.objectweb.celtix.wsdl.WSDLManager;
17:
18: @javax.jws.WebService(serviceName="SOAPService",targetNamespace="http://objectweb.org/callback",endpointInterface="org.objectweb.callback.ServerPortType")
19: //wsdlLocation = "file:./wsdl/basic_callback.wsdl")
20: public class ServerImpl implements ServerPortType {
21:
22: //private static final Logger LOG =
23: // Logger.getLogger(ServerImpl.class.getPackage().getName());
24:
25: public String foo(String s) {
26: return s;
27: }
28:
29: public String registerCallback(EndpointReferenceType callback) {
30:
31: try {
32: Bus bus = Bus.init();
33: WSDLManager manager = new WSDLManagerImpl(bus);
34:
35: QName interfaceName = EndpointReferenceUtils
36: .getInterfaceName(callback);
37: String wsdlLocation = EndpointReferenceUtils
38: .getWSDLLocation(callback);
39: QName serviceName = EndpointReferenceUtils
40: .getServiceName(callback);
41:
42: String portString = EndpointReferenceUtils
43: .getPortName(callback);
44:
45: QName portName = new QName(serviceName.getNamespaceURI(),
46: portString);
47:
48: StringBuffer seiName = new StringBuffer();
49: seiName.append(JAXBUtils
50: .namespaceURIToPackage(interfaceName
51: .getNamespaceURI()));
52: seiName.append(".");
53: seiName.append(JAXBUtils
54: .nameToIdentifier(interfaceName.getLocalPart(),
55: JAXBUtils.IdentifierType.INTERFACE));
56:
57: Class<?> sei = null;
58: try {
59: sei = Class.forName(seiName.toString(), true, manager
60: .getClass().getClassLoader());
61: } catch (ClassNotFoundException ex) {
62: ex.printStackTrace();
63: }
64:
65: URL wsdlURL = (new File(wsdlLocation)).toURL();
66:
67: Service service = Service.create(wsdlURL, serviceName);
68: CallbackPortType port = (CallbackPortType) service.getPort(
69: portName, sei);
70:
71: port.serverSayHi("Sean");
72:
73: bus.shutdown(true);
74:
75: } catch (Exception ex) {
76: ex.printStackTrace();
77: return null;
78: }
79:
80: return "registerCallback called";
81: }
82:
83: }
|