Author: heiko.braun(a)jboss.com
Date: 2009-11-23 08:25:27 -0500 (Mon, 23 Nov 2009)
New Revision: 297
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/InvocationAdapter.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java
trunk/runtime/jbossesb-bpel/src/main/java/org/jboss/soa/esb/actions/bpel/ESBInvocationAdapter.java
Log:
Fix RIFTSAW-91: Incorrect fault returned to client
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/InvocationAdapter.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/InvocationAdapter.java 2009-11-21
00:02:07 UTC (rev 296)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/InvocationAdapter.java 2009-11-23
13:25:27 UTC (rev 297)
@@ -55,6 +55,7 @@
*/
void createResponse(MyRoleMessageExchange mex);
+ void createFault(MyRoleMessageExchange mex);
/**
* Access the invocation result (response)
* @return T
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java 2009-11-21
00:02:07 UTC (rev 296)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java 2009-11-23
13:25:27 UTC (rev 297)
@@ -89,11 +89,6 @@
* This method invokes a BPEL process, associated with the supplied
* service and operation, using the supplied message.
*
- * @param operation The operation name
- * @param service The service QName
- * @param message The message
- * @return A response to the message, or null if no response is
- * required.
* @throws Exception Failed to invoke the operation
*/
public void invoke(InvocationAdapter invocationAdapter)
@@ -242,15 +237,13 @@
case FAULT:
if (__log.isDebugEnabled())
__log.debug("Fault response message: " + mex.getFault());
- throw new BPELFault(mex.getFault(), mex.getFaultResponse().getMessage());
+ invocationAdapter.createFault(mex);
+ // throw new BPELFault(mex.getFault(), mex.getFaultResponse().getMessage());
+ break;
case ASYNC:
case RESPONSE:
- if(true)
- {
- invocationAdapter.createResponse(mex);
- }
-
+ invocationAdapter.createResponse(mex);
if (__log.isDebugEnabled())
__log.debug("Response message " + ret);
break;
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java 2009-11-21
00:02:07 UTC (rev 296)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java 2009-11-23
13:25:27 UTC (rev 297)
@@ -192,7 +192,7 @@
{
Element srcPartEl = DOMUtils.findChildByName(message, new QName(null,
part.getName()));
if (srcPartEl == null)
- throw new RuntimeException("Part is missing" +part.getName());
+ throw new RuntimeException("Part is missing: " +part.getName());
SOAPElement partElement = soapFactory.createElement(srcPartEl);
if (isRPC)
@@ -249,16 +249,62 @@
BindingInput bi = bop.getBindingInput();
if (bi == null)
- throw new RuntimeException("Binding inout not
found"+serviceName+"/"+portName);
-
+ throw new RuntimeException("Binding input not
found"+serviceName+"/"+portName);
+
extractSoapBodyParts(odeMessage, soapMessage, getSOAPBody(bi),
op.getInput().getMessage(), op.getName());
extractSoapHeaderParts(odeMessage, soapMessage, op.getInput().getMessage());
}
- public SOAPFault createSoapFault(Element message, QName faultName, Operation op) {
- throw new RuntimeException("Not implemented");
+ public void createSoapFault(SOAPMessage soapMessage, Element message, QName faultName,
Operation op)
+ {
+ try
+ {
+ Element detail = buildSoapDetail(message, faultName, op);
+ SOAPFault fault = soapMessage.getSOAPBody().addFault();
+ fault.setFaultCode(faultName);
+ if(detail!=null)
+ fault.addDetail().addChildElement(soapFactory.createElement(detail));
+ }
+ catch (SOAPException e)
+ {
+ throw new RuntimeException("Failed to create fault", e);
+ }
}
+ private Element buildSoapDetail(Element message, QName faultName, Operation op)
+ {
+ if (faultName.getNamespaceURI() == null)
+ return toFaultDetail(faultName, message);
+ if (op == null) {
+ return toFaultDetail(faultName, message);
+ }
+ Fault f = op.getFault(faultName.getLocalPart());
+ if (f == null)
+ return toFaultDetail(faultName, message);
+
+ // For faults, there will be exactly one part.
+ Part p = (Part)f.getMessage().getParts().values().iterator().next();
+ if (p == null)
+ return toFaultDetail(faultName, message);
+ Element partEl= DOMUtils.findChildByName(message,new QName(null,p.getName()));
+ if (partEl == null)
+ return toFaultDetail(faultName, message);
+ Element detail = DOMUtils.findChildByName(partEl, p.getElementName());
+ if (detail == null)
+ return toFaultDetail(faultName, message);
+
+ return detail;
+ }
+
+ private Element toFaultDetail(QName fault, Element message) {
+ if (message == null) return null;
+ Element firstPart = DOMUtils.getFirstChildElement(message);
+ if (firstPart == null) return null;
+ Element detail = DOMUtils.getFirstChildElement(firstPart);
+ if (detail == null) return firstPart;
+ return detail;
+ }
+
private void extractSoapHeaderParts(Message odeMessage, SOAPMessage soapMessage,
javax.wsdl.Message wsdlMessageDef)
{
log.warn("extractSoapHeaderParts() not implemented");
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java 2009-11-21
00:02:07 UTC (rev 296)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java 2009-11-23
13:25:27 UTC (rev 297)
@@ -79,10 +79,23 @@
}
catch (SOAPException e)
{
- throw new RuntimeException("Failed to parse SOAP response", e);
+ throw new RuntimeException("Failed to create SOAP response", e);
}
}
+ public void createFault(MyRoleMessageExchange mex)
+ {
+ try
+ {
+ soapResponseMessage = MessageFactory.newInstance().createMessage();
+ soapAdapter.createSoapFault(soapResponseMessage,
mex.getFaultResponse().getMessage(), mex.getFault(), mex.getOperation() );
+ }
+ catch (SOAPException e)
+ {
+ throw new RuntimeException("Failed to create SOAP fault", e);
+ }
+ }
+
public SOAPMessage getInvocationResult()
{
if(null==soapResponseMessage)
Modified:
trunk/runtime/jbossesb-bpel/src/main/java/org/jboss/soa/esb/actions/bpel/ESBInvocationAdapter.java
===================================================================
---
trunk/runtime/jbossesb-bpel/src/main/java/org/jboss/soa/esb/actions/bpel/ESBInvocationAdapter.java 2009-11-21
00:02:07 UTC (rev 296)
+++
trunk/runtime/jbossesb-bpel/src/main/java/org/jboss/soa/esb/actions/bpel/ESBInvocationAdapter.java 2009-11-23
13:25:27 UTC (rev 297)
@@ -71,6 +71,11 @@
this.responseXML = mex.getResponse().getMessage();
}
+ public void createFault(MyRoleMessageExchange mex)
+ {
+ this.responseXML = mex.getFaultResponse().getMessage();
+ }
+
public Element getInvocationResult()
{
return this.responseXML;