Search in sources :

Example 16 with Part

use of javax.wsdl.Part in project cxf by apache.

the class WSIBPValidator method checkR2203And2204.

public boolean checkR2203And2204() {
    Collection<Binding> bindings = CastUtils.cast(def.getBindings().values());
    for (Binding binding : bindings) {
        String style = SOAPBindingUtil.getCanonicalBindingStyle(binding);
        if (binding.getPortType() == null) {
            return true;
        }
        for (Iterator<?> ite2 = binding.getPortType().getOperations().iterator(); ite2.hasNext(); ) {
            Operation operation = (Operation) ite2.next();
            BindingOperation bop = wsdlHelper.getBindingOperation(def, operation.getName());
            if (operation.getInput() != null && operation.getInput().getMessage() != null) {
                Message inMess = operation.getInput().getMessage();
                Set<String> ignorableParts = getIgnorableParts(bop.getBindingInput());
                for (Iterator<?> ite3 = inMess.getParts().values().iterator(); ite3.hasNext(); ) {
                    Part p = (Part) ite3.next();
                    if (SOAPBinding.Style.RPC.name().equalsIgnoreCase(style) && p.getTypeName() == null && !isHeaderPart(bop, p) && !isIgnorablePart(p.getName(), ignorableParts)) {
                        addErrorMessage("An rpc-literal binding in a DESCRIPTION MUST refer, " + "in its soapbind:body element(s), only to " + "wsdl:part element(s) that have been defined " + "using the type attribute.");
                        return false;
                    }
                    if (SOAPBinding.Style.DOCUMENT.name().equalsIgnoreCase(style) && p.getElementName() == null && !isIgnorablePart(p.getName(), ignorableParts)) {
                        addErrorMessage("A document-literal binding in a DESCRIPTION MUST refer, " + "in each of its soapbind:body element(s)," + "only to wsdl:part element(s)" + " that have been defined using the element attribute.");
                        return false;
                    }
                }
            }
            if (operation.getOutput() != null && operation.getOutput().getMessage() != null) {
                Message outMess = operation.getOutput().getMessage();
                Set<String> ignorableParts = getIgnorableParts(bop.getBindingOutput());
                for (Iterator<?> ite3 = outMess.getParts().values().iterator(); ite3.hasNext(); ) {
                    Part p = (Part) ite3.next();
                    if (style.equalsIgnoreCase(SOAPBinding.Style.RPC.name()) && p.getTypeName() == null && !isHeaderPart(bop, p) && !isIgnorablePart(p.getName(), ignorableParts)) {
                        addErrorMessage("An rpc-literal binding in a DESCRIPTION MUST refer, " + "in its soapbind:body element(s), only to " + "wsdl:part element(s) that have been defined " + "using the type attribute.");
                        return false;
                    }
                    if (style.equalsIgnoreCase(SOAPBinding.Style.DOCUMENT.name()) && p.getElementName() == null && !isIgnorablePart(p.getName(), ignorableParts)) {
                        addErrorMessage("A document-literal binding in a DESCRIPTION MUST refer, " + "in each of its soapbind:body element(s)," + "only to wsdl:part element(s)" + " that have been defined using the element attribute.");
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
Also used : SOAPBinding(javax.jws.soap.SOAPBinding) Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation) Message(javax.wsdl.Message) Part(javax.wsdl.Part) MIMEPart(javax.wsdl.extensions.mime.MIMEPart) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation)

Example 17 with Part

use of javax.wsdl.Part in project cxf by apache.

the class WSIBPValidator method checkR2201Output.

private boolean checkR2201Output(final Operation operation, final BindingOperation bop) {
    int outmessagePartsCount = wsdlHelper.getOutMessageParts(operation).size();
    SoapBody soapBody = SOAPBindingUtil.getBindingOutputSOAPBody(bop);
    if (soapBody != null) {
        List<?> parts = soapBody.getParts();
        int boundPartSize = parts == null ? outmessagePartsCount : parts.size();
        SoapHeader soapHeader = SOAPBindingUtil.getBindingOutputSOAPHeader(bop);
        boundPartSize = soapHeader != null && soapHeader.getMessage().equals(operation.getOutput().getMessage().getQName()) ? boundPartSize - 1 : boundPartSize;
        if (parts != null) {
            Iterator<?> partsIte = parts.iterator();
            while (partsIte.hasNext()) {
                String partName = (String) partsIte.next();
                boolean isDefined = false;
                for (Part part : wsdlHelper.getOutMessageParts(operation)) {
                    if (partName.equalsIgnoreCase(part.getName())) {
                        isDefined = true;
                        break;
                    }
                }
                if (!isDefined) {
                    addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2201") + "Operation '" + operation.getName() + "' soapBody parts : " + partName + " not found in the message, wrong WSDL");
                    return false;
                }
            }
        } else {
            if (wsdlHelper.getOutMessageParts(operation).size() > 1) {
                addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2210") + "Operation '" + operation.getName() + "' more than one part bound to body");
                return false;
            }
        }
        if (boundPartSize > 1) {
            addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2201") + "Operation '" + operation.getName() + "' more than one part bound to body");
            return false;
        }
    }
    return true;
}
Also used : Part(javax.wsdl.Part) MIMEPart(javax.wsdl.extensions.mime.MIMEPart) SoapBody(org.apache.cxf.binding.soap.wsdl.extensions.SoapBody) SoapHeader(org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader)

Example 18 with Part

use of javax.wsdl.Part in project cxf by apache.

the class WSDLToSoapProcessor method validate.

private void validate() throws ToolException {
    if (isBindingExisted()) {
        Message msg = new Message("BINDING_ALREADY_EXIST", LOG);
        throw new ToolException(msg);
    }
    if (!isPortTypeExisted()) {
        Message msg = new Message("PORTTYPE_NOT_EXIST", LOG);
        throw new ToolException(msg);
    }
    if (!nameSpaceCheck()) {
        Message msg = new Message("SOAPBINDING_STYLE_NOT_PROVIDED", LOG);
        throw new ToolException(msg);
    }
    if (WSDLConstants.RPC.equalsIgnoreCase((String) env.get(ToolConstants.CFG_STYLE))) {
        Collection<Operation> ops = CastUtils.cast(portType.getOperations());
        for (Operation op : ops) {
            Input input = op.getInput();
            if (input != null && input.getMessage() != null) {
                Collection<Part> parts = CastUtils.cast(input.getMessage().getParts().values());
                for (Part part : parts) {
                    if (part.getTypeName() == null || "".equals(part.getTypeName().toString())) {
                        Message msg = new Message("RPC_PART_ILLEGAL", LOG, new Object[] { part.getName() });
                        throw new ToolException(msg);
                    }
                }
            }
            Output output = op.getOutput();
            if (output != null && output.getMessage() != null) {
                Collection<Part> parts = CastUtils.cast(output.getMessage().getParts().values());
                for (Part part : parts) {
                    if (part.getTypeName() == null || "".equals(part.getTypeName().toString())) {
                        Message msg = new Message("RPC_PART_ILLEGAL", LOG, new Object[] { part.getName() });
                        throw new ToolException(msg);
                    }
                }
            }
        }
    }
}
Also used : BindingInput(javax.wsdl.BindingInput) Input(javax.wsdl.Input) Message(org.apache.cxf.common.i18n.Message) Part(javax.wsdl.Part) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) ToolException(org.apache.cxf.tools.common.ToolException) Operation(javax.wsdl.Operation) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) BindingOperation(javax.wsdl.BindingOperation)

Example 19 with Part

use of javax.wsdl.Part in project carbon-business-process by wso2.

the class SOAPUtils method handleSoapHeaderPartDef.

private static void handleSoapHeaderPartDef(org.apache.ode.bpel.iapi.Message odeMessage, Definition wsdl, SOAPHeader header, javax.wsdl.extensions.soap.SOAPHeader headerdef, Message msgType) throws BPELFault {
    // Is this header part of the "payload" messsage?
    boolean payloadMessageHeader = headerdef.getMessage() == null || headerdef.getMessage().equals(msgType.getQName());
    boolean requiredHeader = payloadMessageHeader || (headerdef.getRequired() != null && headerdef.getRequired());
    if (requiredHeader && header == null) {
        throw new BPELFault("SOAP Header missing required element.");
    }
    if (header == null) {
        return;
    }
    Message hdrMsg = wsdl.getMessage(headerdef.getMessage());
    if (hdrMsg == null) {
        return;
    }
    Part p = hdrMsg.getPart(headerdef.getPart());
    if (p == null || p.getElementName() == null) {
        return;
    }
    OMElement headerEl = header.getFirstChildWithName(p.getElementName());
    if (requiredHeader && headerEl == null) {
        throw new BPELFault("SOAP Header missing required element: " + p.getElementName());
    }
    if (headerEl == null) {
        return;
    }
    odeMessage.setHeaderPart(p.getName(), OMUtils.toDOM(headerEl));
}
Also used : BPELFault(org.wso2.carbon.bpel.core.ode.integration.BPELFault) Message(javax.wsdl.Message) Part(javax.wsdl.Part) OMElement(org.apache.axiom.om.OMElement)

Example 20 with Part

use of javax.wsdl.Part in project carbon-business-process by wso2.

the class SOAPUtils method buildSoapDetail.

private static OMElement buildSoapDetail(final BPELMessageContext bpelMessageContext, final MessageExchange odeMessageContext) throws AxisFault {
    Element message = odeMessageContext.getResponse().getMessage();
    QName faultName = odeMessageContext.getFault();
    Operation operation = odeMessageContext.getOperation();
    SOAPFactory soapFactory = bpelMessageContext.getSoapFactoryForCurrentMessageFlow();
    if (faultName.getNamespaceURI() == null) {
        return toFaultDetail(message, soapFactory);
    }
    Fault f = operation.getFault(faultName.getLocalPart());
    if (f == null) {
        return toFaultDetail(message, soapFactory);
    }
    // For faults, there will be exactly one part.
    Part p = (Part) f.getMessage().getParts().values().iterator().next();
    if (p == null) {
        return toFaultDetail(message, soapFactory);
    }
    Element partEl = DOMUtils.findChildByName(message, new QName(null, p.getName()));
    if (partEl == null) {
        return toFaultDetail(message, soapFactory);
    }
    Element detail = DOMUtils.findChildByName(partEl, p.getElementName());
    if (detail == null) {
        return toFaultDetail(message, soapFactory);
    }
    return OMUtils.toOM(detail, soapFactory);
}
Also used : QName(javax.xml.namespace.QName) Part(javax.wsdl.Part) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) SOAPFault(org.apache.axiom.soap.SOAPFault) Fault(javax.wsdl.Fault) AxisFault(org.apache.axis2.AxisFault) BPELFault(org.wso2.carbon.bpel.core.ode.integration.BPELFault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) SOAPFactory(org.apache.axiom.soap.SOAPFactory)

Aggregations

Part (javax.wsdl.Part)49 QName (javax.xml.namespace.QName)30 Message (javax.wsdl.Message)21 Operation (javax.wsdl.Operation)11 BindingOperation (javax.wsdl.BindingOperation)9 Input (javax.wsdl.Input)9 Output (javax.wsdl.Output)7 OMElement (org.apache.axiom.om.OMElement)7 Element (org.w3c.dom.Element)7 ArrayList (java.util.ArrayList)6 Binding (javax.wsdl.Binding)6 OpenEJBException (org.apache.openejb.OpenEJBException)6 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)6 Fault (javax.wsdl.Fault)5 Port (javax.wsdl.Port)5 Service (javax.wsdl.Service)5 MIMEPart (javax.wsdl.extensions.mime.MIMEPart)5 List (java.util.List)4 BindingInput (javax.wsdl.BindingInput)4 PortType (javax.wsdl.PortType)4