Search in sources :

Example 1 with SOAPBody

use of javax.wsdl.extensions.soap.SOAPBody in project tdi-studio-se by Talend.

the class ComponentBuilder method buildOperation.

private OperationInfo buildOperation(OperationInfo operationInfo, BindingOperation bindingOper) {
    Operation oper = bindingOper.getOperation();
    operationInfo.setTargetMethodName(oper.getName());
    Vector operElems = findExtensibilityElement(bindingOper.getExtensibilityElements(), "operation");
    ExtensibilityElement operElem = (ExtensibilityElement) operElems.elementAt(0);
    if (operElem != null && operElem instanceof SOAPOperation) {
        SOAPOperation soapOperation = (SOAPOperation) operElem;
        operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
    } else if (operElem != null && operElem instanceof SOAP12Operation) {
        SOAP12Operation soapOperation = (SOAP12Operation) operElem;
        operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
    }
    BindingInput bindingInput = bindingOper.getBindingInput();
    BindingOutput bindingOutput = bindingOper.getBindingOutput();
    Vector bodyElems = findExtensibilityElement(bindingInput.getExtensibilityElements(), "body");
    ExtensibilityElement bodyElem = (ExtensibilityElement) bodyElems.elementAt(0);
    if (bodyElem != null && bodyElem instanceof SOAPBody) {
        SOAPBody soapBody = (SOAPBody) bodyElem;
        List styles = soapBody.getEncodingStyles();
        String encodingStyle = null;
        if (styles != null) {
            encodingStyle = styles.get(0).toString();
        }
        if (encodingStyle == null) {
            encodingStyle = DEFAULT_SOAP_ENCODING_STYLE;
        }
        operationInfo.setEncodingStyle(encodingStyle.toString());
        operationInfo.setTargetObjectURI(soapBody.getNamespaceURI());
    } else if (bodyElem != null && bodyElem instanceof SOAP12Body) {
        SOAP12Body soapBody = (SOAP12Body) bodyElem;
        String encodingStyle = null;
        if (soapBody.getEncodingStyle() != null) {
            encodingStyle = soapBody.getEncodingStyle().toString();
        }
        if (encodingStyle == null) {
            encodingStyle = DEFAULT_SOAP_ENCODING_STYLE;
        }
        operationInfo.setEncodingStyle(encodingStyle.toString());
        operationInfo.setTargetObjectURI(soapBody.getNamespaceURI());
    }
    Input inDef = oper.getInput();
    if (inDef != null) {
        Message inMsg = inDef.getMessage();
        if (inMsg != null) {
            operationInfo.setInputMessageName(inMsg.getQName().getLocalPart());
            getParameterFromMessage(operationInfo, inMsg, 1);
            operationInfo.setInmessage(inMsg);
        }
    }
    Output outDef = oper.getOutput();
    if (outDef != null) {
        Message outMsg = outDef.getMessage();
        if (outMsg != null) {
            operationInfo.setOutputMessageName(outMsg.getQName().getLocalPart());
            getParameterFromMessage(operationInfo, outMsg, 2);
            operationInfo.setOutmessage(outMsg);
        }
    }
    return operationInfo;
}
Also used : SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) BindingOutput(javax.wsdl.BindingOutput) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) Message(javax.wsdl.Message) Operation(javax.wsdl.Operation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) BindingOperation(javax.wsdl.BindingOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) BindingInput(javax.wsdl.BindingInput) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) SOAPBody(javax.wsdl.extensions.soap.SOAPBody) Input(javax.wsdl.Input) BindingInput(javax.wsdl.BindingInput) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) List(java.util.List) ArrayList(java.util.ArrayList) Vector(java.util.Vector)

Example 2 with SOAPBody

use of javax.wsdl.extensions.soap.SOAPBody in project carbon-business-process by wso2.

the class WSDLAwareSOAPProcessor method processMessageParts.

private WSDLAwareMessage processMessageParts(BindingInput bindingInput) throws AxisFault {
    WSDLAwareMessage message = new WSDLAwareMessage();
    message.setBinding(wsdlBinding);
    List parts;
    String namespace;
    if (soap12) {
        SOAP12Body soapBodyDef = getFirstExtensibilityElement(bindingInput, SOAP12Body.class);
        if (soapBodyDef == null) {
            String errMessage = "SOAPBody null for binding input.";
            log.error(errMessage);
            throw new AxisFault(errMessage);
        }
        parts = soapBodyDef.getParts();
        namespace = soapBodyDef.getNamespaceURI();
    } else {
        SOAPBody soapBodyDef = getFirstExtensibilityElement(bindingInput, SOAPBody.class);
        if (soapBodyDef == null) {
            String errMessage = "SOAPBody null for binding input.";
            log.error(errMessage);
            throw new AxisFault(errMessage);
        }
        parts = soapBodyDef.getParts();
        namespace = soapBodyDef.getNamespaceURI();
    }
    QName axisOperationName = inMessageCtx.getAxisOperation().getName();
    /**
     * Local part of the axis Operation's name equals to WSDL Operation name.
     */
    Operation op = wsdlBinding.getPortType().getOperation(axisOperationName.getLocalPart(), null, null);
    String rpcWrapper = op.getName();
    List bodyParts = op.getInput().getMessage().getOrderedParts(parts);
    if (isRPC) {
        message.setRPC(true);
        QName rpWrapperQName = new QName(namespace, rpcWrapper);
        OMElement partWrapper = inMessageCtx.getEnvelope().getBody().getFirstChildWithName(rpWrapperQName);
        if (partWrapper == null) {
            String errMsg = "SOAP Body doesn't contain expected part wrapper.";
            log.error(errMsg);
            throw new AxisFault(errMsg);
        }
        /* In RPC the body element is the operation name, wrapping parts. Order doesn't really
             * matter as far as we're concerned. All we need to do is copy the soap:body children,
             * since doc-lit rpc looks the same in ode and soap.*/
        for (Object partDef : bodyParts) {
            OMElement srcPart = partWrapper.getFirstChildWithName(new QName(null, ((Part) partDef).getName()));
            if (srcPart == null) {
                throw new AxisFault("SOAP Body doesn't contain required part " + ((Part) partDef).getName() + ".");
            }
            message.addBodyPart(srcPart.getLocalName(), srcPart);
        }
    } else {
        /**
         * In doc-literal style, we expect the elements in the body to correspond (in order) to
         * the parts defined in the binding. All the parts should be element-typed, otherwise
         * it is a mess.
         */
        message.setRPC(false);
        Iterator srcParts = inMessageCtx.getEnvelope().getBody().getChildElements();
        for (Object partDef : bodyParts) {
            if (!srcParts.hasNext()) {
                throw new AxisFault("SOAP Body does not contain required part" + ((Part) partDef).getName() + ".");
            }
            OMElement srcPart = (OMElement) srcParts.next();
            if (((Part) partDef).getElementName() == null) {
                throw new AxisFault("Binding defines non-element document literal part(s)");
            }
            if (!srcPart.getQName().equals(((Part) partDef).getElementName())) {
                throw new AxisFault("Unexpected element in SOAP body.");
            }
            message.addBodyPart(((Part) partDef).getName(), srcPart);
        }
    }
    processSoapHeaderParts(message, bindingInput, op);
    return message;
}
Also used : AxisFault(org.apache.axis2.AxisFault) SOAPBody(javax.wsdl.extensions.soap.SOAPBody) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) QName(javax.xml.namespace.QName) Part(javax.wsdl.Part) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) OMElement(org.apache.axiom.om.OMElement) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation)

Example 3 with SOAPBody

use of javax.wsdl.extensions.soap.SOAPBody in project carbon-business-process by wso2.

the class WSDLAwareSOAPProcessor method processMessageParts.

private WSDLAwareMessage processMessageParts(BindingInput bindingInput) throws AxisFault {
    WSDLAwareMessage message = new WSDLAwareMessage();
    message.setTenantId(this.tenantId);
    SOAPBody soapBodyDef = getFirstExtensibilityElement(bindingInput, SOAPBody.class);
    if (soapBodyDef == null) {
        String errMessage = "SOAPBody null for binding input.";
        log.error(errMessage);
        throw new AxisFault(errMessage);
    }
    QName axisOperationName = inMessageCtx.getAxisOperation().getName();
    /**
     * Local part of the axis Operation's name equals to WSDL Operation name.
     */
    Operation op = wsdlBinding.getPortType().getOperation(axisOperationName.getLocalPart(), null, null);
    message.setPortTypeName(wsdlBinding.getPortType().getQName());
    message.setOperationName(op.getName());
    String rpcWrapper = op.getName();
    List bodyParts = op.getInput().getMessage().getOrderedParts(soapBodyDef.getParts());
    if (isRPC) {
        // message.setRPC(true);
        QName rpWrapperQName = new QName(wsdlBinding.getQName().getNamespaceURI(), rpcWrapper);
        OMElement partWrapper = inMessageCtx.getEnvelope().getBody().getFirstChildWithName(rpWrapperQName);
        if (partWrapper == null) {
            String errMsg = "SOAP Body doesn't contain expected part wrapper.";
            log.error(errMsg);
            throw new AxisFault(errMsg);
        }
        /* In RPC the body element is the operation name, wrapping parts. Order doesn't really
             * matter as far as we're concerned. All we need to do is copy the soap:body children,
             * since doc-lit rpc looks the same in ode and soap.*/
        for (Object partDef : bodyParts) {
            OMElement srcPart = partWrapper.getFirstChildWithName(new QName(null, ((Part) partDef).getName()));
            if (srcPart == null) {
                throw new AxisFault("SOAP Body doesn't contain required part " + ((Part) partDef).getName() + ".");
            }
            message.addBodyPart(srcPart.getLocalName(), srcPart);
        }
    } else {
        /**
         * In doc-literal style, we expect the elements in the body to correspond (in order) to
         * the parts defined in the binding. All the parts should be element-typed, otherwise
         * it is a mess.
         */
        // message.setRPC(false);
        Iterator srcParts = inMessageCtx.getEnvelope().getBody().getChildElements();
        for (Object partDef : bodyParts) {
            if (!srcParts.hasNext()) {
                throw new AxisFault("SOAP Body does not contain required part" + ((Part) partDef).getName() + ".");
            }
            OMElement srcPart = (OMElement) srcParts.next();
            if (((Part) partDef).getElementName() == null) {
                throw new AxisFault("Binding defines non-element document literal part(s)");
            }
            if (!srcPart.getQName().equals(((Part) partDef).getElementName())) {
                throw new AxisFault("Unexpected element in SOAP body: " + srcPart.getQName() + " \nExpected: " + ((Part) partDef).getElementName());
            }
            message.addBodyPart(((Part) partDef).getName(), srcPart);
        }
    }
    processSoapHeaderParts(message, bindingInput, op);
    return message;
}
Also used : AxisFault(org.apache.axis2.AxisFault) SOAPBody(javax.wsdl.extensions.soap.SOAPBody) QName(javax.xml.namespace.QName) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) OMElement(org.apache.axiom.om.OMElement)

Example 4 with SOAPBody

use of javax.wsdl.extensions.soap.SOAPBody in project tomee by apache.

the class LightWeightMappingValidator method visit.

@Override
protected void visit(BindingFault bindingFault) {
    SOAPBody body = getSOAPBody(bindingFault.getExtensibilityElements());
    String encoding = body.getUse();
    if (encoding == null || !encoding.equals("encoded")) {
        context.addFailure(new ValidationFailure("The use attribute of the binding fault operation must be 'encoded': " + bindingFault.getName()));
    }
}
Also used : SOAPBody(javax.wsdl.extensions.soap.SOAPBody) ValidationFailure(org.apache.openejb.config.ValidationFailure)

Example 5 with SOAPBody

use of javax.wsdl.extensions.soap.SOAPBody in project cxf by apache.

the class PartialWSDLProcessor method getSoapBody.

private static SOAPBody getSoapBody(Class<?> parent, ExtensionRegistry extReg) throws Exception {
    SOAPBody soapBody = SOAPBindingUtil.createSoapBody(extReg, parent, false);
    soapBody.setUse(useLiteral);
    return soapBody;
}
Also used : SOAPBody(javax.wsdl.extensions.soap.SOAPBody)

Aggregations

SOAPBody (javax.wsdl.extensions.soap.SOAPBody)12 BindingOperation (javax.wsdl.BindingOperation)7 BindingInput (javax.wsdl.BindingInput)6 QName (javax.xml.namespace.QName)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 BindingOutput (javax.wsdl.BindingOutput)3 Operation (javax.wsdl.Operation)3 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)3 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)3 ValidationFailure (org.apache.openejb.config.ValidationFailure)3 Iterator (java.util.Iterator)2 Binding (javax.wsdl.Binding)2 Input (javax.wsdl.Input)2 Message (javax.wsdl.Message)2 Output (javax.wsdl.Output)2 Part (javax.wsdl.Part)2 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 SOAP12Body (javax.wsdl.extensions.soap12.SOAP12Body)2 OMElement (org.apache.axiom.om.OMElement)2