Search in sources :

Example 1 with SoapHeader

use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.

the class HeaderUtil method getHeaderQNames.

private static Set<QName> getHeaderQNames(BindingMessageInfo bmi) {
    Set<QName> set = new HashSet<>();
    List<MessagePartInfo> mps = bmi.getMessageInfo().getMessageParts();
    List<ExtensibilityElement> extList = bmi.getExtensors(ExtensibilityElement.class);
    if (extList != null) {
        for (ExtensibilityElement ext : extList) {
            if (SOAPBindingUtil.isSOAPHeader(ext)) {
                SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);
                String pn = header.getPart();
                for (MessagePartInfo mpi : mps) {
                    if (pn.equals(mpi.getName().getLocalPart())) {
                        if (mpi.isElement()) {
                            set.add(mpi.getElementQName());
                        } else {
                            set.add(mpi.getTypeQName());
                        }
                        break;
                    }
                }
            }
        }
    }
    return set;
}
Also used : QName(javax.xml.namespace.QName) SoapHeader(org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) HashSet(java.util.HashSet)

Example 2 with SoapHeader

use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.

the class SOAPBindingUtil method getBindingOutputSOAPHeaders.

public static List<SoapHeader> getBindingOutputSOAPHeaders(BindingOperation bop) {
    List<SoapHeader> headers = new ArrayList<>();
    BindingOutput bindingOutput = bop.getBindingOutput();
    if (bindingOutput != null) {
        for (Object obj : bindingOutput.getExtensibilityElements()) {
            if (isSOAPHeader(obj)) {
                headers.add(getProxy(SoapHeader.class, obj));
            }
        }
    }
    return headers;
}
Also used : BindingOutput(javax.wsdl.BindingOutput) ArrayList(java.util.ArrayList) SoapHeader(org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader)

Example 3 with SoapHeader

use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.

the class SOAPBindingUtil method getBindingInputSOAPHeaders.

public static List<SoapHeader> getBindingInputSOAPHeaders(BindingOperation bop) {
    List<SoapHeader> headers = new ArrayList<>();
    BindingInput bindingInput = bop.getBindingInput();
    if (bindingInput != null) {
        for (Object obj : bindingInput.getExtensibilityElements()) {
            if (isSOAPHeader(obj)) {
                headers.add(getProxy(SoapHeader.class, obj));
            }
        }
    }
    return headers;
}
Also used : ArrayList(java.util.ArrayList) SoapHeader(org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader) BindingInput(javax.wsdl.BindingInput)

Example 4 with SoapHeader

use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.

the class SoapBindingFactory method addMessageFromBinding.

protected void addMessageFromBinding(ExtensibilityElement ext, BindingOperationInfo bop, boolean isInput) {
    SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);
    ServiceInfo serviceInfo = bop.getBinding().getService();
    if (header != null && header.getMessage() == null) {
        throw new RuntimeException("Problem with WSDL: soap:header element" + " for operation " + bop.getName() + " under binding " + bop.getBinding().getName() + " does not contain a valid message attribute.");
    }
    if (header != null && serviceInfo.getMessage(header.getMessage()) == null) {
        Definition def = (Definition) serviceInfo.getProperty(WSDLServiceBuilder.WSDL_DEFINITION);
        SchemaCollection schemas = serviceInfo.getXmlSchemaCollection();
        if (def != null && schemas != null) {
            QName qn = header.getMessage();
            javax.wsdl.Message msg = findMessage(qn, def);
            if (msg != null) {
                addOutOfBandParts(bop, msg, schemas, isInput, header.getPart());
                serviceInfo.refresh();
            } else {
                throw new RuntimeException("Problem with WSDL: soap:header element" + " for operation " + bop.getName() + " is referring to an undefined wsdl:message element: " + qn);
            }
        }
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) SoapHeader(org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader) SchemaCollection(org.apache.cxf.common.xmlschema.SchemaCollection)

Example 5 with SoapHeader

use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader 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)

Aggregations

SoapHeader (org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader)14 SoapBody (org.apache.cxf.binding.soap.wsdl.extensions.SoapBody)8 QName (javax.xml.namespace.QName)7 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)5 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)4 ArrayList (java.util.ArrayList)3 MIMEPart (javax.wsdl.extensions.mime.MIMEPart)3 SoapHeaderInfo (org.apache.cxf.binding.soap.model.SoapHeaderInfo)3 SoapFault (org.apache.cxf.binding.soap.wsdl.extensions.SoapFault)3 Part (javax.wsdl.Part)2 MIMEMultipartRelated (javax.wsdl.extensions.mime.MIMEMultipartRelated)2 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)2 MessageInfo (org.apache.cxf.service.model.MessageInfo)2 HashSet (java.util.HashSet)1 BindingInput (javax.wsdl.BindingInput)1 BindingOutput (javax.wsdl.BindingOutput)1 Definition (javax.wsdl.Definition)1 ExtensionRegistry (javax.wsdl.extensions.ExtensionRegistry)1 MIMEContent (javax.wsdl.extensions.mime.MIMEContent)1 Bus (org.apache.cxf.Bus)1