Author: objectiser
Date: 2010-02-16 07:55:31 -0500 (Tue, 16 Feb 2010)
New Revision: 499
Added:
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3-cxf.xml
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3-native.xml
Removed:
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3.xml
Modified:
trunk/integration-tests/src/test/java/org/jboss/soa/bpel/tests/samples/QuickstartBPELLoanApprovalTestCase.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/WebServiceClient.java
Log:
RIFTSAW-162 - fixed - fault returned via an exception, rather than a SOAP message, when
using cxf.
Modified:
trunk/integration-tests/src/test/java/org/jboss/soa/bpel/tests/samples/QuickstartBPELLoanApprovalTestCase.java
===================================================================
---
trunk/integration-tests/src/test/java/org/jboss/soa/bpel/tests/samples/QuickstartBPELLoanApprovalTestCase.java 2010-02-15
14:57:38 UTC (rev 498)
+++
trunk/integration-tests/src/test/java/org/jboss/soa/bpel/tests/samples/QuickstartBPELLoanApprovalTestCase.java 2010-02-16
12:55:31 UTC (rev 499)
@@ -78,13 +78,10 @@
// If testing against cxf, then result is presented slightly differently
if (result.indexOf("SOAP-ENV") != -1) {
- result = result.replaceAll("SOAP-ENV", "env");
- result = result.replaceAll(" xmlns=\"\"","");
- result = result.replaceAll("\"","'");
- result = result.replaceAll("<env:Header
/>","<env:Header></env:Header>");
+ assertMessageFromFile(result, "loanresp3-cxf.xml");
+ } else {
+ assertMessageFromFile(result, "loanresp3-native.xml");
}
-
- assertMessageFromFile(result, "loanresp3.xml");
}
public void testSendLoanRequest4() throws Exception {
Added:
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3-cxf.xml
===================================================================
---
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3-cxf.xml
(rev 0)
+++
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3-cxf.xml 2010-02-16
12:55:31 UTC (rev 499)
@@ -0,0 +1 @@
+<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">&...
/><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode
xmlns:ns0="http://example.com/loan-approval/wsdl/">ns0:unabl...
string, and possibly fault code, not set</faultstring><detail><integer
xmlns="http://example.com/loan-approval/xsd/error-messages/">...
\ No newline at end of file
Copied:
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3-native.xml
(from rev 497,
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3.xml)
===================================================================
---
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3-native.xml
(rev 0)
+++
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3-native.xml 2010-02-16
12:55:31 UTC (rev 499)
@@ -0,0 +1 @@
+<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:...
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><faul...
xmlns:valueNS='http://example.com/loan-approval/wsdl/'>valueNS...
xmlns:ns1='http://example.com/loan-approval/xsd/error-messages/'&...
\ No newline at end of file
Deleted:
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3.xml
===================================================================
---
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3.xml 2010-02-15
14:57:38 UTC (rev 498)
+++
trunk/integration-tests/src/test/resources/samples/Quickstart_bpel_loan_approval/messages/loanresp3.xml 2010-02-16
12:55:31 UTC (rev 499)
@@ -1 +0,0 @@
-<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:...
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><faul...
xmlns:valueNS='http://example.com/loan-approval/wsdl/'>valueNS...
xmlns:ns1='http://example.com/loan-approval/xsd/error-messages/'&...
\ No newline at end of file
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 2010-02-15
14:57:38 UTC (rev 498)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java 2010-02-16
12:55:31 UTC (rev 499)
@@ -37,6 +37,7 @@
import javax.wsdl.extensions.soap.SOAPHeader;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
+
import java.util.*;
/**
@@ -552,6 +553,34 @@
return fdef;
}
+ public Fault parseSoapFault(
+ Element odeMessage,
+ SOAPFault flt,
+ javax.wsdl.Operation operation)
+ {
+ Fault fault=inferFault(operation, flt);
+
+ if(fault!=null)
+ {
+ Detail detail = flt.getDetail();
+ Part pdef = (Part)fault.getMessage().getParts().values().iterator().next();
+ Element partel =
odeMessage.getOwnerDocument().createElementNS(null,pdef.getName());
+ odeMessage.appendChild(partel);
+
+ Element childByName = DOMUtils.findChildByName(detail, pdef.getElementName());
+ if (childByName != null)
+ {
+ partel.appendChild(odeMessage.getOwnerDocument().importNode(childByName,
true));
+ }
+ else
+ {
+ partel.appendChild(odeMessage.getOwnerDocument().importNode(detail,true));
+ }
+ }
+
+ return fault;
+ }
+
private Fault inferFault(Operation operation, SOAPFault flt) {
if (!flt.hasDetail())
return null;
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceClient.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceClient.java 2010-02-15
14:57:38 UTC (rev 498)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceClient.java 2010-02-16
12:55:31 UTC (rev 499)
@@ -135,53 +135,48 @@
// The actual WS invocation
Dispatch proxy = getDispatcher(port);
- SOAPMessage soapResponseMessage =
(SOAPMessage)proxy.invoke(soapRequestMessage);
+
+ try {
+ SOAPMessage soapResponseMessage =
(SOAPMessage)proxy.invoke(soapRequestMessage);
+
+ // Create ODE response
+ Message odeResponse =
mex.createMessage(mex.getOperation().getOutput().getMessage().getQName());
+ if(soapResponseMessage.getSOAPBody().hasFault())
+ {
+ // fault handling
+ Document odeMsg = DOMUtils.newDocument();
+ Element odeMsgEl = odeMsg.createElementNS(null,
"message");
+ odeMsg.appendChild(odeMsgEl);
+
+ Fault fault = messageAdapter.parseSoapFault(
+ odeMsgEl, soapResponseMessage, mex.getOperation()
+ );
+
+ handleFault(mex, fault,
soapResponseMessage.getSOAPBody().getFault(), odeMsgEl);
+
+ }
+ else
+ {
+
messageAdapter.parseSoapResponse(odeResponse,soapResponseMessage,mex.getOperation());
+ mex.reply(odeResponse);
+ }
+
+ if(log.isDebugEnabled())
+ log.debug( "ODE inbound message: \n"
+DOMWriter.printNode(odeResponse.getMessage(), true) );
+
+ } catch(javax.xml.ws.soap.SOAPFaultException fe) {
+
+ // fault handling
+ Document odeMsg = DOMUtils.newDocument();
+ Element odeMsgEl = odeMsg.createElementNS(null,
"message");
+ odeMsg.appendChild(odeMsgEl);
+
+ Fault fault=messageAdapter.parseSoapFault(odeMsgEl,
fe.getFault(),
+ mex.getOperation());
- // Create ODE response
- Message odeResponse =
mex.createMessage(mex.getOperation().getOutput().getMessage().getQName());
- if(soapResponseMessage.getSOAPBody().hasFault())
- {
- // fault handling
- Document odeMsg = DOMUtils.newDocument();
- Element odeMsgEl = odeMsg.createElementNS(null,
"message");
- odeMsg.appendChild(odeMsgEl);
-
- Fault fault = messageAdapter.parseSoapFault(
- odeMsgEl, soapResponseMessage, mex.getOperation()
- );
-
- if (fault != null)
- {
- if (log.isWarnEnabled())
- log.warn("Fault response: faultName="
- + fault.getName() + " faultType=" +
fault.getMessage().getQName()
- + "\n" + DOMWriter.printNode(odeMsgEl, true));
-
- QName faultType = fault.getMessage().getQName();
- QName faultName = new QName(wsdlDefintion.getTargetNamespace(),
fault.getName());
- Message response = mex.createMessage(faultType);
- response.setMessage(odeMsgEl);
-
- mex.replyWithFault(faultName, response);
- }
- else
- {
- if (log.isWarnEnabled())
- log.warn("Fault response: faultType=(unknown)");
-
- SOAPFault f = soapResponseMessage.getSOAPBody().getFault();
- mex.replyWithFailure(MessageExchange.FailureType.OTHER,
"Unspecified", f.getDetail());
- }
+ handleFault(mex, fault, fe.getFault(), odeMsgEl);
}
- else
- {
-
messageAdapter.parseSoapResponse(odeResponse,soapResponseMessage,mex.getOperation());
- mex.reply(odeResponse);
- }
- if(log.isDebugEnabled())
- log.debug( "ODE inbound message: \n"
+DOMWriter.printNode(odeResponse.getMessage(), true) );
-
tx.commit();
}
catch (Throwable e)
@@ -242,7 +237,32 @@
mex.replyOneWayOk();
}
}
+
+ private void handleFault(PartnerRoleMessageExchange mex, Fault fault, SOAPFault
soapFault,
+ Element odeMsgEl) {
+ if (fault != null)
+ {
+ if (log.isWarnEnabled())
+ log.warn("Fault response: faultName="
+ + fault.getName() + " faultType=" +
fault.getMessage().getQName()
+ + "\n" + DOMWriter.printNode(odeMsgEl, true));
+ QName faultType = fault.getMessage().getQName();
+ QName faultName = new QName(wsdlDefintion.getTargetNamespace(),
fault.getName());
+ Message response = mex.createMessage(faultType);
+ response.setMessage(odeMsgEl);
+
+ mex.replyWithFault(faultName, response);
+ }
+ else
+ {
+ if (log.isWarnEnabled())
+ log.warn("Fault response: faultType=(unknown)");
+
+ mex.replyWithFailure(MessageExchange.FailureType.OTHER, "Unspecified",
soapFault.getDetail());
+ }
+ }
+
private UserTransaction getUserTransaction()
throws NamingException
{