Search in sources :

Example 1 with CallbackPortType

use of org.apache.nested_callback.CallbackPortType in project cxf by apache.

the class ServerImpl method registerCallback.

public String registerCallback(NestedCallback callbackObject) {
    try {
        W3CEndpointReference w3cEpr = callbackObject.getCallback();
        EndpointReferenceType callback = ProviderImpl.convertToInternal(w3cEpr);
        WSDLManager manager = new WSDLManagerImpl();
        QName interfaceName = EndpointReferenceUtils.getInterfaceName(callback, bus);
        String wsdlLocation = EndpointReferenceUtils.getWSDLLocation(callback);
        QName serviceName = EndpointReferenceUtils.getServiceName(callback, bus);
        String address = EndpointReferenceUtils.getAddress(callback);
        String portString = EndpointReferenceUtils.getPortName(callback);
        QName portName = new QName(serviceName.getNamespaceURI(), portString);
        StringBuilder seiName = new StringBuilder();
        seiName.append(JAXBUtils.namespaceURIToPackage(interfaceName.getNamespaceURI()));
        seiName.append(".");
        seiName.append(JAXBUtils.nameToIdentifier(interfaceName.getLocalPart(), JAXBUtils.IdentifierType.INTERFACE));
        Class<?> sei = null;
        try {
            sei = Class.forName(seiName.toString(), true, manager.getClass().getClassLoader());
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
        URL wsdlURL = new URL(wsdlLocation);
        Service service = Service.create(wsdlURL, serviceName);
        CallbackPortType port = (CallbackPortType) service.getPort(portName, sei);
        ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
        port.serverSayHi("Sean");
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
    return "registerCallback called";
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) QName(javax.xml.namespace.QName) WSDLManagerImpl(org.apache.cxf.wsdl11.WSDLManagerImpl) Service(javax.xml.ws.Service) URL(java.net.URL) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) CallbackPortType(org.apache.nested_callback.CallbackPortType) WSDLManager(org.apache.cxf.wsdl.WSDLManager)

Aggregations

URL (java.net.URL)1 QName (javax.xml.namespace.QName)1 Service (javax.xml.ws.Service)1 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)1 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)1 WSDLManager (org.apache.cxf.wsdl.WSDLManager)1 WSDLManagerImpl (org.apache.cxf.wsdl11.WSDLManagerImpl)1 CallbackPortType (org.apache.nested_callback.CallbackPortType)1