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;
}
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());
}
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);
}
}
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);
}
}
Aggregations