Search in sources :

Example 1 with Message

use of org.apache.ode.bpel.iapi.Message in project carbon-business-process by wso2.

the class BPELProcessProxy method createInputMessageToODE.

private Message createInputMessageToODE(final BPELMessageContext bpelMessageContext, final MyRoleMessageExchange messageExchange) throws AxisFault {
    // Preparing message to send to ODE
    Message odeRequest = messageExchange.createMessage(messageExchange.getOperation().getInput().getMessage().getQName());
    fillODEMessage(odeRequest, bpelMessageContext.getRequestMessage());
    return odeRequest;
}
Also used : Message(org.apache.ode.bpel.iapi.Message) WSDLAwareMessage(org.wso2.carbon.bpel.core.ode.integration.axis2.WSDLAwareMessage)

Example 2 with Message

use of org.apache.ode.bpel.iapi.Message in project carbon-business-process by wso2.

the class BPELProcessProxy method invokeBPELProcessThroughODEMessageExchange.

private Future invokeBPELProcessThroughODEMessageExchange(final MyRoleMessageExchange odeMessageExchange, final BPELMessageContext bpelMessageContext) throws AxisFault {
    Message request = createInputMessageToODE(bpelMessageContext, odeMessageExchange);
    if (log.isDebugEnabled()) {
        log.debug("Invoking ODE using MEX " + odeMessageExchange);
        log.debug("Message content:  " + DOMUtils.domToString(request.getMessage()));
    }
    return odeMessageExchange.invoke(request, bpelMessageContext.getAttachmentIDList());
}
Also used : Message(org.apache.ode.bpel.iapi.Message) WSDLAwareMessage(org.wso2.carbon.bpel.core.ode.integration.axis2.WSDLAwareMessage)

Example 3 with Message

use of org.apache.ode.bpel.iapi.Message in project carbon-business-process by wso2.

the class PartnerService method replyHTTP.

private void replyHTTP(final BPELMessageContext partnerInvocationContext, final PartnerRoleMessageExchange odeMex, final boolean isFault) {
    try {
        if (log.isDebugEnabled()) {
            log.debug("Received response for MEX " + odeMex);
        }
        if (isFault) {
            Document odeMsg = DOMUtils.newDocument();
            Element odeMsgEl = odeMsg.createElementNS(null, "message");
            odeMsg.appendChild(odeMsgEl);
            QName faultType = new QName("http://wso2.org/bps/fault", "HTTPBindingFault");
            QName faultName = new QName("http://wso2.org/bps/fault", "RESTPartnerServiceError");
            Element fault = odeMsg.createElementNS(null, "fault");
            fault.setTextContent("Error returned from REST Partner");
            odeMsgEl.appendChild(fault);
            Message response = odeMex.createMessage(faultType);
            response.setMessage(odeMsgEl);
            odeMex.replyWithFault(faultName, response);
        } else {
            Message response = SOAPUtils.parseResponseFromRESTService(partnerInvocationContext, odeMex);
            if (log.isDebugEnabled()) {
                log.debug("Response:\n" + (response.getMessage() != null ? DOMUtils.domToString(response.getMessage()) : "empty"));
            }
            odeMex.reply(response);
        }
    } catch (Exception ex) {
        String errmsg = "Unable to process response: " + ex.getMessage();
        log.error(errmsg, ex);
        odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, errmsg, null);
    }
}
Also used : Message(org.apache.ode.bpel.iapi.Message) QName(javax.xml.namespace.QName) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Example 4 with Message

use of org.apache.ode.bpel.iapi.Message in project carbon-business-process by wso2.

the class PartnerService method reply.

private void reply(final BPELMessageContext partnerInvocationContext, final PartnerRoleMessageExchange odeMex, final Operation operation, final MessageContext reply, final boolean isFault) {
    try {
        if (log.isDebugEnabled()) {
            log.debug("Received response for MEX " + odeMex);
        }
        if (isFault) {
            Document odeMsg = DOMUtils.newDocument();
            Element odeMsgEl = odeMsg.createElementNS(null, "message");
            odeMsg.appendChild(odeMsgEl);
            Fault fault = SOAPUtils.parseSoapFault(odeMsgEl, reply.getEnvelope(), operation);
            if (fault != null) {
                if (log.isWarnEnabled()) {
                    log.warn("Fault response: faultName=" + fault.getName() + " faultType=" + fault.getMessage().getQName() + "\n" + DOMUtils.domToString(odeMsgEl));
                }
                QName faultType = fault.getMessage().getQName();
                QName faultName = new QName(wsdlDefinition.getTargetNamespace(), fault.getName());
                Message response = odeMex.createMessage(faultType);
                response.setMessage(odeMsgEl);
                odeMex.replyWithFault(faultName, response);
            } else {
                SOAPFault soapFault = reply.getEnvelope().getBody().getFault();
                QName faultType = new QName(wsdlDefinition.getTargetNamespace(), "UnknownFault");
                Message response = odeMex.createMessage(faultType);
                Element actAsPart = odeMsgEl.getOwnerDocument().createElementNS(null, soapFault.getLocalName());
                odeMsgEl.appendChild(actAsPart);
                if (soapFault.getCode() != null) {
                    actAsPart.appendChild(odeMsgEl.getOwnerDocument().importNode(OMUtils.toDOM(soapFault.getCode()), true));
                }
                if (soapFault.getReason() != null) {
                    actAsPart.appendChild(odeMsgEl.getOwnerDocument().importNode(OMUtils.toDOM(soapFault.getReason()), true));
                }
                if (log.isWarnEnabled()) {
                    log.warn("Fault response: " + DOMUtils.domToString(odeMsgEl));
                }
                response.setMessage(odeMsgEl);
                odeMex.replyWithFault(faultType, response);
            }
        } else {
            Message response = SOAPUtils.parseSOAPResponseFromPartner(partnerInvocationContext, odeMex);
            if (log.isDebugEnabled()) {
                log.debug("Response:\n" + (response.getMessage() != null ? DOMUtils.domToString(response.getMessage()) : "empty"));
            }
            odeMex.reply(response);
        }
    } catch (BPELFault bpelFault) {
        handleError(odeMex, bpelFault);
    } catch (AxisFault axisFault) {
        handleError(odeMex, axisFault);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) Message(org.apache.ode.bpel.iapi.Message) QName(javax.xml.namespace.QName) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Element(org.w3c.dom.Element) SOAPFault(org.apache.axiom.soap.SOAPFault) Fault(javax.wsdl.Fault) AxisFault(org.apache.axis2.AxisFault) SOAPFault(org.apache.axiom.soap.SOAPFault) Document(org.w3c.dom.Document)

Aggregations

Message (org.apache.ode.bpel.iapi.Message)4 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 QName (javax.xml.namespace.QName)2 Document (org.w3c.dom.Document)2 Element (org.w3c.dom.Element)2 WSDLAwareMessage (org.wso2.carbon.bpel.core.ode.integration.axis2.WSDLAwareMessage)2 Fault (javax.wsdl.Fault)1 SOAPFault (org.apache.axiom.soap.SOAPFault)1 AxisFault (org.apache.axis2.AxisFault)1