Search in sources :

Example 1 with ExtensionRegistry

use of javax.wsdl.extensions.ExtensionRegistry in project cxf by apache.

the class SoapBindingFactory method createSoapBinding.

private void createSoapBinding(final SoapBindingInfo bi) throws WSDLException {
    boolean isSoap12 = bi.getSoapVersion() instanceof Soap12;
    Bus bs = getBus();
    WSDLManager m = bs.getExtension(WSDLManager.class);
    ExtensionRegistry extensionRegistry = m.getExtensionRegistry();
    SoapBinding soapBinding = SOAPBindingUtil.createSoapBinding(extensionRegistry, isSoap12);
    soapBinding.setStyle(bi.getStyle());
    soapBinding.setTransportURI(bi.getTransportURI());
    bi.addExtensor(soapBinding);
    for (BindingOperationInfo b : bi.getOperations()) {
        for (BindingFaultInfo faultInfo : b.getFaults()) {
            SoapFault soapFault = SOAPBindingUtil.createSoapFault(extensionRegistry, isSoap12);
            soapFault.setUse("literal");
            soapFault.setName(faultInfo.getFaultInfo().getFaultName().getLocalPart());
            faultInfo.addExtensor(soapFault);
        }
        SoapOperationInfo soi = b.getExtensor(SoapOperationInfo.class);
        SoapOperation soapOperation = SOAPBindingUtil.createSoapOperation(extensionRegistry, isSoap12);
        soapOperation.setSoapActionURI(soi.getAction());
        soapOperation.setStyle(soi.getStyle());
        boolean isRpc = "rpc".equals(soapOperation.getStyle());
        b.addExtensor(soapOperation);
        if (b.getInput() != null) {
            List<String> bodyParts = null;
            List<SoapHeaderInfo> headerInfos = b.getInput().getExtensors(SoapHeaderInfo.class);
            if (headerInfos != null && !headerInfos.isEmpty()) {
                bodyParts = new ArrayList<>();
                for (MessagePartInfo part : b.getInput().getMessageParts()) {
                    bodyParts.add(part.getName().getLocalPart());
                }
                for (SoapHeaderInfo headerInfo : headerInfos) {
                    SoapHeader soapHeader = SOAPBindingUtil.createSoapHeader(extensionRegistry, BindingInput.class, isSoap12);
                    soapHeader.setMessage(b.getInput().getMessageInfo().getName());
                    soapHeader.setPart(headerInfo.getPart().getName().getLocalPart());
                    soapHeader.setUse("literal");
                    bodyParts.remove(headerInfo.getPart().getName().getLocalPart());
                    headerInfo.getPart().setProperty(HEADER, true);
                    b.getInput().addExtensor(soapHeader);
                }
            }
            SoapBody body = SOAPBindingUtil.createSoapBody(extensionRegistry, BindingInput.class, isSoap12);
            body.setUse("literal");
            if (isRpc) {
                body.setNamespaceURI(b.getName().getNamespaceURI());
            }
            if (bodyParts != null) {
                body.setParts(bodyParts);
            }
            b.getInput().addExtensor(body);
        }
        if (b.getOutput() != null) {
            List<String> bodyParts = null;
            List<SoapHeaderInfo> headerInfos = b.getOutput().getExtensors(SoapHeaderInfo.class);
            if (headerInfos != null && !headerInfos.isEmpty()) {
                bodyParts = new ArrayList<>();
                for (MessagePartInfo part : b.getOutput().getMessageParts()) {
                    bodyParts.add(part.getName().getLocalPart());
                }
                for (SoapHeaderInfo headerInfo : headerInfos) {
                    SoapHeader soapHeader = SOAPBindingUtil.createSoapHeader(extensionRegistry, BindingOutput.class, isSoap12);
                    soapHeader.setMessage(b.getOutput().getMessageInfo().getName());
                    soapHeader.setPart(headerInfo.getPart().getName().getLocalPart());
                    soapHeader.setUse("literal");
                    bodyParts.remove(headerInfo.getPart().getName().getLocalPart());
                    b.getOutput().addExtensor(soapHeader);
                }
            }
            SoapBody body = SOAPBindingUtil.createSoapBody(extensionRegistry, BindingOutput.class, isSoap12);
            body.setUse("literal");
            if (isRpc) {
                body.setNamespaceURI(b.getName().getNamespaceURI());
            }
            if (bodyParts != null) {
                body.setParts(bodyParts);
            }
            b.getOutput().addExtensor(body);
        }
    }
}
Also used : Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) SoapFault(org.apache.cxf.binding.soap.wsdl.extensions.SoapFault) SoapHeaderInfo(org.apache.cxf.binding.soap.model.SoapHeaderInfo) SoapBody(org.apache.cxf.binding.soap.wsdl.extensions.SoapBody) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) ExtensionRegistry(javax.wsdl.extensions.ExtensionRegistry) WSDLManager(org.apache.cxf.wsdl.WSDLManager) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) SoapHeader(org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo)

Example 2 with ExtensionRegistry

use of javax.wsdl.extensions.ExtensionRegistry in project cxf by apache.

the class SchemaFactoryImpl method newDefinition.

/**
 * Create a new instance of a Definition, with an instance of a
 * PopulatedExtensionRegistry as its ExtensionRegistry.
 */
public Definition newDefinition() {
    Definition def = factory.newDefinition();
    ExtensionRegistry extReg = newPopulatedExtensionRegistry();
    def.setExtensionRegistry(extReg);
    return def;
}
Also used : Definition(javax.wsdl.Definition) ExtensionRegistry(javax.wsdl.extensions.ExtensionRegistry)

Example 3 with ExtensionRegistry

use of javax.wsdl.extensions.ExtensionRegistry in project cxf by apache.

the class WSDLCorbaFactoryImpl method newDefinition.

/**
 * Create a new instance of a Definition, with an instance of a
 * PopulatedExtensionRegistry as its ExtensionRegistry.
 */
public Definition newDefinition() {
    Definition def = factory.newDefinition();
    ExtensionRegistry extReg = newPopulatedExtensionRegistry();
    def.setExtensionRegistry(extReg);
    return def;
}
Also used : Definition(javax.wsdl.Definition) ExtensionRegistry(javax.wsdl.extensions.ExtensionRegistry)

Example 4 with ExtensionRegistry

use of javax.wsdl.extensions.ExtensionRegistry in project tomee by apache.

the class CommonsSchemaLoader method readWsdl.

private Definition readWsdl(URI wsdlURI) throws OpenEJBException {
    Definition definition;
    WSDLFactory wsdlFactory;
    try {
        wsdlFactory = WSDLFactory.newInstance();
    } catch (WSDLException e) {
        throw new OpenEJBException("Could not create WSDLFactory", e);
    }
    WSDLReader wsdlReaderNoImport = wsdlFactory.newWSDLReader();
    wsdlReaderNoImport.setFeature("javax.wsdl.importDocuments", false);
    ExtensionRegistry extensionRegistry = new PopulatedExtensionRegistry();
    extensionRegistry.mapExtensionTypes(Types.class, SchemaConstants.Q_ELEM_XSD_1999, UnknownExtensibilityElement.class);
    extensionRegistry.registerDeserializer(Types.class, SchemaConstants.Q_ELEM_XSD_1999, extensionRegistry.getDefaultDeserializer());
    extensionRegistry.registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_1999, extensionRegistry.getDefaultSerializer());
    extensionRegistry.mapExtensionTypes(Types.class, SchemaConstants.Q_ELEM_XSD_2000, UnknownExtensibilityElement.class);
    extensionRegistry.registerDeserializer(Types.class, SchemaConstants.Q_ELEM_XSD_2000, extensionRegistry.getDefaultDeserializer());
    extensionRegistry.registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_2000, extensionRegistry.getDefaultSerializer());
    extensionRegistry.mapExtensionTypes(Types.class, SchemaConstants.Q_ELEM_XSD_2001, UnknownExtensibilityElement.class);
    extensionRegistry.registerDeserializer(Types.class, SchemaConstants.Q_ELEM_XSD_2001, extensionRegistry.getDefaultDeserializer());
    extensionRegistry.registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_2001, extensionRegistry.getDefaultSerializer());
    wsdlReaderNoImport.setExtensionRegistry(extensionRegistry);
    JarWSDLLocator wsdlLocator = new JarWSDLLocator(wsdlURI);
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    Thread thread = Thread.currentThread();
    ClassLoader oldCl = thread.getContextClassLoader();
    thread.setContextClassLoader(this.getClass().getClassLoader());
    try {
        try {
            definition = wsdlReader.readWSDL(wsdlLocator);
        } catch (WSDLException e) {
            throw new OpenEJBException("Failed to read wsdl document", e);
        } catch (RuntimeException e) {
            throw new OpenEJBException(e.getMessage(), e);
        }
    } finally {
        thread.setContextClassLoader(oldCl);
    }
    return definition;
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) PopulatedExtensionRegistry(com.ibm.wsdl.extensions.PopulatedExtensionRegistry) ServerRuntimeException(org.apache.openejb.server.ServerRuntimeException) WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLException(javax.wsdl.WSDLException) Definition(javax.wsdl.Definition) WSDLReader(javax.wsdl.xml.WSDLReader) ExtensionRegistry(javax.wsdl.extensions.ExtensionRegistry) PopulatedExtensionRegistry(com.ibm.wsdl.extensions.PopulatedExtensionRegistry)

Example 5 with ExtensionRegistry

use of javax.wsdl.extensions.ExtensionRegistry in project cxf by apache.

the class JaxWsEndpointImpl method buildWsdlExtensibilities.

private void buildWsdlExtensibilities(BindingInfo bindingInfo) {
    Addressing addressing = getAddressing();
    if (addressing != null) {
        ExtensionRegistry extensionRegistry = getBus().getExtension(WSDLManager.class).getExtensionRegistry();
        try {
            ExtensibilityElement el = extensionRegistry.createExtension(javax.wsdl.Binding.class, JAXWSAConstants.WSAW_USINGADDRESSING_QNAME);
            el.setRequired(addressing.required());
            bindingInfo.addExtensor(el);
            StringBuilder polRefId = new StringBuilder(bindingInfo.getName().getLocalPart());
            polRefId.append("_WSAM_Addressing_Policy");
            UnknownExtensibilityElement uel = new UnknownExtensibilityElement();
            W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
            writer.writeStartElement("wsp", "PolicyReference", URI_POLICY_NS);
            writer.writeAttribute("URI", "#" + polRefId.toString());
            writer.writeEndElement();
            Element pr = writer.getDocument().getDocumentElement();
            uel.setElement(pr);
            uel.setElementType(DOMUtils.getElementQName(pr));
            bindingInfo.addExtensor(uel);
            writer = new W3CDOMStreamWriter();
            writer.writeStartElement("wsp", "Policy", URI_POLICY_NS);
            writer.writeAttribute("wsu", URI_WSU_NS, "Id", polRefId.toString());
            writer.writeStartElement("wsam", "Addressing", JAXWSAConstants.NS_WSAM);
            if (!addressing.required()) {
                writer.writeAttribute("wsp", URI_POLICY_NS, "Optional", "true");
            }
            writer.writeStartElement("wsp", "Policy", URI_POLICY_NS);
            String s = getAddressingRequirement(addressing);
            if (s != null) {
                writer.writeEmptyElement("wsam", s, JAXWSAConstants.NS_WSAM);
            }
            writer.writeEndElement();
            writer.writeEndElement();
            writer.writeEndElement();
            pr = writer.getDocument().getDocumentElement();
            uel = new UnknownExtensibilityElement();
            uel.setElement(pr);
            uel.setElementType(DOMUtils.getElementQName(pr));
            if (bindingInfo.getService().getDescription() == null) {
                DescriptionInfo description = new DescriptionInfo();
                description.setName(bindingInfo.getService().getName());
                bindingInfo.getService().setDescription(description);
            }
            bindingInfo.getService().getDescription().addExtensor(uel);
        } catch (Exception e) {
            // ignore
            e.printStackTrace();
        }
    }
}
Also used : W3CDOMStreamWriter(org.apache.cxf.staxutils.W3CDOMStreamWriter) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Element(org.w3c.dom.Element) WSDLManager(org.apache.cxf.wsdl.WSDLManager) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) Addressing(javax.xml.ws.soap.Addressing) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) WebServiceException(javax.xml.ws.WebServiceException) EndpointException(org.apache.cxf.endpoint.EndpointException) ExtensionRegistry(javax.wsdl.extensions.ExtensionRegistry)

Aggregations

ExtensionRegistry (javax.wsdl.extensions.ExtensionRegistry)8 WSDLException (javax.wsdl.WSDLException)4 Definition (javax.wsdl.Definition)3 WSDLManager (org.apache.cxf.wsdl.WSDLManager)3 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 UnknownExtensibilityElement (javax.wsdl.extensions.UnknownExtensibilityElement)2 WSDLFactory (javax.wsdl.factory.WSDLFactory)2 PopulatedExtensionRegistry (com.ibm.wsdl.extensions.PopulatedExtensionRegistry)1 Map (java.util.Map)1 Binding (javax.wsdl.Binding)1 PortType (javax.wsdl.PortType)1 Types (javax.wsdl.Types)1 WSDLReader (javax.wsdl.xml.WSDLReader)1 QName (javax.xml.namespace.QName)1 WebServiceException (javax.xml.ws.WebServiceException)1 Addressing (javax.xml.ws.soap.Addressing)1 Bus (org.apache.cxf.Bus)1 SoapHeaderInfo (org.apache.cxf.binding.soap.model.SoapHeaderInfo)1 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)1 SoapAddress (org.apache.cxf.binding.soap.wsdl.extensions.SoapAddress)1