Bug 1080697

Summary: Null details in SOAP fault returned to Camel Route
Product: [JBoss] JBoss Fuse Service Works 6 Reporter: Wayne Toh <wtoh>
Component: SwitchYardAssignee: Aileen <aileenc>
Status: ON_QA --- QA Contact: Matej Melko <mmelko>
Severity: high Docs Contact:
Priority: high    
Version: 6.0.0 GACC: aileenc, jochen.riedlinger, rcernich, rwagner, soa-p-jira, tasato
Target Milestone: CR1   
Target Release: One-off release   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1146233 1146241 (view as bug list) Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1146233, 1146241    
Attachments:
Description Flags
External WS by Wayne
none
Proxy by Wayne
none
Patch to test
none
server log by Magesh
none
additional patch
none
modified bean none

Description Wayne Toh 2014-03-26 01:11:45 UTC
Description of problem:

I am currently having a SOAP consumer that has a CAMEL implementation that calls a web service. The returned response from the backend is a SOAP fault. I wish to get the fault details and return a custom/modelled SOAP response back to the caller via a messagecomposer. However, in the CAMEL exchange, the fault details are null. 
 
Version-Release number of selected component (if applicable):

switchyard runtime version is 1.1.1-p5

How reproducible:

Always

Steps to Reproduce:
1. Create a web service provider that returns a SOAP fault detail
2. Create a web service consumer that implements a Camel route and calls the backend web service via SOAP binding
3. Invoke the web service consumer

Actual results:

In Camel, exchange.EXCEPTION_CAUGHT exception message has the details as null

Expected results:

The SOAP fault details should be present in the exchange.EXCEPTION_CAUGHT exception message

Additional info:

The SOAPMessageComposer.java is returning a detailNode

try {
            if (soapBody.hasFault()) {
                // peel off the Fault element
                SOAPFault fault = soapBody.getFault();
                if (fault.hasDetail()) {
                    Detail detail = fault.getDetail();
                    // We only support one entry at this moment
                    DetailEntry entry = null;
                    Iterator<DetailEntry> entries = detail.getDetailEntries();
                    if (entries.hasNext()) {
                        entry = entries.next();
                    }
                    if (entry != null) {
                        Node detailNode = entry.getParentNode().removeChild(entry);
                        message.setContent(detailNode);
                        return message;
                    }
                }
            }

Comment 1 Magesh Kumar Bojan 2014-03-27 13:38:25 UTC
Created attachment 879487 [details]
External WS by Wayne

Comment 2 Magesh Kumar Bojan 2014-03-27 13:39:02 UTC
Created attachment 879488 [details]
Proxy by Wayne

Comment 3 Magesh Kumar Bojan 2014-03-27 13:47:00 UTC
Created attachment 879502 [details]
Patch to test

Hi Wayne,

I am attaching a patch that needs to be copied onto modules/system/layers/soa/org/switchyard/component/camel/switchyard/main

Please test this and let me know.

Comment 4 Wayne Toh 2014-03-28 02:05:14 UTC
Hi Magesh

I have tested it. The behaviour still remains the same. I am not seeing the details in the exception message.

Comment 5 Magesh Kumar Bojan 2014-03-28 13:12:31 UTC
Hi Wayne,

With handleFault set to false, in soapUI I get the following result:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/>
   <soap:Body>
      <SOAP-ENV:Fault xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
         <faultcode>SOAP-ENV:Fault</faultcode>
         <faultstring>SWITCHYARD035448: Send Failed</faultstring>
         <detail>
            <PO:order xmlns:PO="http://webservice_producer/goodbyeworld">
               <symbol xmlns="http://webservice_producer/goodbyeworld">SUNW</symbol>
            </PO:order>
         </detail>
      </SOAP-ENV:Fault>
   </soap:Body>
</soap:Envelope>

and with handleFault set to true, I see this in the log:

[stdout] (http-/127.0.0.1:8080-25) =====in exception handling Service======
[stdout] (http-/127.0.0.1:8080-25) ======== The exception is =======CamelExceptionCaught
[stdout] (http-/127.0.0.1:8080-25) ======== switchyard exchange msg is =======[PO:order: null]

Could you be more specific as to what is null? Please not I tested the sayGoodbye method. I will attach my log for both the test run

Comment 6 Magesh Kumar Bojan 2014-03-28 13:16:15 UTC
Created attachment 879827 [details]
server log by Magesh

Comment 7 Wayne Toh 2014-03-31 01:19:20 UTC
Hi Magesh

When handleFault is set to true, as you have tested, the exception message becomes
[PO:order: null]

The whole fault details should be seen as below in the camel exception. As without the details the fault handler will not be able to model and return a custom fault back to the consumer. 
<PO:order xmlns:PO="http://webservice_producer/goodbyeworld">
               <symbol xmlns="http://webservice_producer/goodbyeworld">SUNW</symbol>
            </PO:order>

Comment 8 Magesh Kumar Bojan 2014-03-31 06:55:22 UTC
Wayne,

The exception message is a org.w3c.dom.Node. If you properly print the node in the bean, then the entire detail will be there.

Comment 9 Magesh Kumar Bojan 2014-04-04 05:45:53 UTC
Okay, I have attached another patch that goes along with the earlier one. This needs to be copied onto modules/system/layers/soa/org/switchyard/component/soap/main

I have changed the way to retrieve the fault details in hihiServiceBean. I have attached that too. Please note there is no need to use any custom composer.

Comment 10 Magesh Kumar Bojan 2014-04-04 05:46:56 UTC
Created attachment 882522 [details]
additional patch

Comment 11 Magesh Kumar Bojan 2014-04-04 05:47:49 UTC
Created attachment 882523 [details]
modified bean

Comment 12 Wayne Toh 2014-04-07 05:37:12 UTC
Hi Magesh, it is now working as expected.