[ 
https://issues.apache.org/jira/browse/CXF-3442?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Willem Jiang resolved CXF-3442.
-------------------------------

    Resolution: Fixed

> Fault should not swallow the cause exception message
> ----------------------------------------------------
>
>                 Key: CXF-3442
>                 URL: https://issues.apache.org/jira/browse/CXF-3442
>             Project: CXF
>          Issue Type: Improvement
>          Components: Soap Binding
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>            Priority: Minor
>             Fix For: 2.4, 2.3.4
>
>
> When sending an invalid SOAP message specifically with an incorrect end tag:
> {code}
> snip...
>   <soapenv:Body>
>       <cus:lookupCustomer>
>          <customerId>1</customerId>
>          <customerId2>1</customerId2>
>       <cus:lookupCustomer>   <------- no slash.
>    </soapenv:Body>
> end snip..
> {code}
> The wrong SOAP fault is thrown when using the WSS4JInInterceptor:
> {code}
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
>    <soap:Body>
>       <soap:Fault>
>          <faultcode>soap:Client</faultcode>
>          <faultstring>Problems creating SAAJ object model</faultstring>
>       </soap:Fault>
>    </soap:Body>
> </soap:Envelope>
> {code}
> When the WSS4JInInterceptor is removed the following exception is thrown:
> {code}
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
>    <soap:Body>
>       <soap:Fault>
>          <faultcode>soap:Client</faultcode>
>          <faultstring>Unmarshalling Error: cvc-complex-type.2.4.d: Invalid 
> content was found starting with element 'cus:lookupCustomer'. No child 
> element is expected at this point.</faultstring>
>       </soap:Fault>
>    </soap:Body>
> </soap:Envelope>
> {code}
> If you enable the WSS4JInInterceptor, CXF will use SAAJInInterceptor to 
> create a SOAP message for using.
> That could explain that you got the "Problems creating SAAJ object model" 
> message.
> I just checked the code of SAAJInInterceptor, it just wrap the real cause of 
> exception message like this
> {code}
> } catch (SOAPException soape) {
>             throw new SoapFault(new org.apache.cxf.common.i18n.Message(
>                     "SOAPHANDLERINTERCEPTOR_EXCEPTION", BUNDLE), soape,
>                     message.getVersion().getSender());
>         } catch (XMLStreamException e) {
>             throw new SoapFault(new org.apache.cxf.common.i18n.Message(
>                     "SOAPHANDLERINTERCEPTOR_EXCEPTION", BUNDLE), e, message
>                     .getVersion().getSender());
>         }
> {code}
> After digging the code more, I found the SoapFault and it's parent Fault 
> doesn't take the cause exception into consideration.
> When the Fault reason send to the client, it just a Fault message without the 
> cause. It's difficult for the user to trace the real cause of the exception. 
> My suggestion is change the Fault class to add the cause exception message 
> into the Fault message like this
> {code}
>     public Fault(Message message, Throwable throwable) {
>         super(message, throwable);
>         this.message = message.toString;
>         if (throwable != null) {
>            this.message += "Caused by: " + throwable.getMessage();
>         }
>         code = FAULT_CODE_SERVER;
>     }
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to