Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SOAPFaultException.getFault().getDetail() is null

I am calling a SOAP webservice using JAX WS 2.0. In the case of error I am getting the following response:

<?xml version="1.0"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-   envelope">
    <soap:Header/>
    <soap:Body>
        <soap:Fault  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap- envelope" xmlns:xml="http://www.w3.org/XML/1998/namespace">
            <soap:Code>  
                <soap:Value>soap:Receiver</soap:Value>
            </soap:Code>
            <soap:Reason>
                <soap:Text  xml:lang="en">Exception of type 'blah blah' was thrown.
                </soap:Text>
            </soap:Reason>
            <soap:Node>{SOME URL}</soap:Node>
            <detail>
                <error>345</error>
                <message>Cannot find user. Blah  blah</message>
            </detail>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

As you can see the useful error is in the detail node:

<soap:Envelope>  
    <soap:Body>  
        <soap:Fault>  
            <detail>

In my client I am getting a SOAPFaultException which has a SOAPFault object. The SOAPFault object seems to be missing the node I posted above. SOAPFaultException.getFault().getDetail() is null. However, it has every other node including the soap:Reason. Any idea why it is missing the detail node?

Thanks.

like image 567
user1910629 Avatar asked Oct 22 '22 22:10

user1910629


1 Answers

It turns out that the detail node needs to include the SOAP namespace as well. So it needs to be:

<soap:detail>

Since I don't have control over the web service I managed to make this change in the handleFault method of a custom SOAPHandler I injected into my client. After that change, the detail of the fault is no longer null and has all the sub nodes.

Based on, http://www.w3.org/TR/soap12-part1/#soapfault, I believe the developer needs to correct the response during a Fault.

like image 176
user1910629 Avatar answered Oct 24 '22 17:10

user1910629