Search in sources :

Example 1 with BPELMessageContext

use of org.wso2.carbon.bpel.core.ode.integration.BPELMessageContext in project carbon-business-process by wso2.

the class AxisServiceUtils method invokeService.

public static void invokeService(BPELMessageContext partnerInvocationContext, ConfigurationContext configContext) throws AxisFault {
    MessageContext mctx = partnerInvocationContext.getInMessageContext();
    OperationClient opClient = getOperationClient(partnerInvocationContext, configContext);
    mctx.getOptions().setParent(opClient.getOptions());
    /*
        Else we assume that the epr is not changed by the process.
        In this case there's a limitation we cannot invoke the epr in the wsdl
        (by assingning that epr by partnerlink assign) if there is a endpoint
        configuration available for that particular service
        */
    addCustomHeadersToMessageContext(mctx);
    opClient.addMessageContext(mctx);
    Options operationOptions = opClient.getOptions();
    if (partnerInvocationContext.getUep().isAddressingEnabled()) {
        // Currently we set the action manually, but this should be handled by
        // addressing module it-self?
        String action = getAction(partnerInvocationContext);
        if (log.isDebugEnabled()) {
            log.debug("Soap action: " + action);
        }
        operationOptions.setAction(action);
    // TODO set replyto as well
    // operationOptions.setReplyTo(mctx.getReplyTo());
    }
    if (partnerInvocationContext.getUep().getAddress() == null) {
        partnerInvocationContext.getUep().setAddress(getEPRfromWSDL(partnerInvocationContext.getBpelServiceWSDLDefinition(), partnerInvocationContext.getService(), partnerInvocationContext.getPort()));
    }
    operationOptions.setTo(partnerInvocationContext.getUep());
    opClient.execute(true);
    if (partnerInvocationContext.isTwoWay()) {
        partnerInvocationContext.setOutMessageContext(opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
        partnerInvocationContext.setFaultMessageContext(opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_FAULT_VALUE));
    }
}
Also used : OperationClient(org.apache.axis2.client.OperationClient) Options(org.apache.axis2.client.Options) BPELMessageContext(org.wso2.carbon.bpel.core.ode.integration.BPELMessageContext) MessageContext(org.apache.axis2.context.MessageContext)

Example 2 with BPELMessageContext

use of org.wso2.carbon.bpel.core.ode.integration.BPELMessageContext 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)

Example 3 with BPELMessageContext

use of org.wso2.carbon.bpel.core.ode.integration.BPELMessageContext in project carbon-business-process by wso2.

the class SOAPUtils method parseSOAPResponseFromPartner.

public static org.apache.ode.bpel.iapi.Message parseSOAPResponseFromPartner(BPELMessageContext partnerInvocationContext, MessageExchange partnerRoleMessageExchange) throws BPELFault {
    org.apache.ode.bpel.iapi.Message messageToODE = partnerRoleMessageExchange.createMessage(partnerRoleMessageExchange.getOperation().getOutput().getMessage().getQName());
    BindingOperation bindingOp = getBindingOperation(partnerInvocationContext, partnerRoleMessageExchange.getOperationName());
    BindingOutput bindingOutPut = getBindingOutPut(bindingOp);
    SOAPEnvelope responseFromPartnerService = partnerInvocationContext.getOutMessageContext().getEnvelope();
    if (partnerInvocationContext.isSoap12()) {
        javax.wsdl.extensions.soap12.SOAP12Body soapBodyDefinition = getSOAP12Body(bindingOutPut);
        if (soapBodyDefinition != null) {
            if (responseFromPartnerService.getBody() != null) {
                extractSOAPBodyParts(partnerRoleMessageExchange, messageToODE, responseFromPartnerService.getBody(), soapBodyDefinition.getParts(), soapBodyDefinition.getNamespaceURI(), partnerInvocationContext.isRPCStyleOperation());
            } else {
                throw new BPELFault("SOAP Body cannot be null for WSDL operation which " + "requires SOAP Body.");
            }
        }
    } else {
        javax.wsdl.extensions.soap.SOAPBody soapBodyDefinition = getSOAP11Body(bindingOutPut);
        if (soapBodyDefinition != null) {
            if (responseFromPartnerService.getBody() != null) {
                extractSOAPBodyParts(partnerRoleMessageExchange, messageToODE, responseFromPartnerService.getBody(), soapBodyDefinition.getParts(), soapBodyDefinition.getNamespaceURI(), partnerInvocationContext.isRPCStyleOperation());
            } else {
                throw new BPELFault("SOAP Body cannot be null for WSDL operation which " + "requires SOAP Body.");
            }
        }
    }
    if (getSOAPHeaders(bindingOutPut) != null && responseFromPartnerService.getHeader() != null) {
        extractSoapHeaderParts(messageToODE, partnerInvocationContext.getBpelServiceWSDLDefinition(), responseFromPartnerService.getHeader(), getSOAPHeaders(bindingOutPut), partnerRoleMessageExchange.getOperation().getOutput().getMessage());
    }
    return messageToODE;
}
Also used : BindingOutput(javax.wsdl.BindingOutput) BPELFault(org.wso2.carbon.bpel.core.ode.integration.BPELFault) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) OMNode(org.apache.axiom.om.OMNode) Node(org.w3c.dom.Node) BindingOperation(javax.wsdl.BindingOperation) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body)

Example 4 with BPELMessageContext

use of org.wso2.carbon.bpel.core.ode.integration.BPELMessageContext 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 5 with BPELMessageContext

use of org.wso2.carbon.bpel.core.ode.integration.BPELMessageContext 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)

Aggregations

BPELMessageContext (org.wso2.carbon.bpel.core.ode.integration.BPELMessageContext)6 MessageContext (org.apache.axis2.context.MessageContext)3 BindingOperation (javax.wsdl.BindingOperation)2 SOAPFactory (org.apache.axiom.soap.SOAPFactory)2 AxisFault (org.apache.axis2.AxisFault)2 WSDL11Endpoint (org.apache.ode.bpel.epr.WSDL11Endpoint)2 Message (org.apache.ode.bpel.iapi.Message)2 BPELFault (org.wso2.carbon.bpel.core.ode.integration.BPELFault)2 WSDLAwareMessage (org.wso2.carbon.bpel.core.ode.integration.axis2.WSDLAwareMessage)2 UnifiedEndpoint (org.wso2.carbon.unifiedendpoint.core.UnifiedEndpoint)2 SocketException (java.net.SocketException)1 UUID (java.util.UUID)1 BindingOutput (javax.wsdl.BindingOutput)1 Fault (javax.wsdl.Fault)1 Operation (javax.wsdl.Operation)1 Part (javax.wsdl.Part)1 SOAP12Body (javax.wsdl.extensions.soap12.SOAP12Body)1 QName (javax.xml.namespace.QName)1 OMElement (org.apache.axiom.om.OMElement)1 OMNode (org.apache.axiom.om.OMNode)1