I want to throw my own custom exceptions through Spring-WS. I write my Exception class like this :
@SoapFault(faultCode = FaultCode.CUSTOM, customFaultCode = "{http://www.myorg.com/test}INVALID_INPUT_DATA")
public class InvalidDataException extends Exception
{
public InvalidDataException(String errorMsg)
{
super(errorMsg);
}
public InvalidDataException(Throwable t)
{
super(t);
}
}
When my service throws this exception with a text parameter, I get a good soapFault with my customFaultCode as a subCode :
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header/>
<env:Body>
<env:Fault>
<env:Code>
<env:Value>env:Receiver</env:Value>
<env:Subcode>
<env:Value xmlns:ns1="http://www.myorg.com/test">ns1:INVALID_INPUT_DATA</env:Value>
</env:Subcode>
</env:Code>
<env:Reason>
<env:Text xml:lang="en">WTF! Something wrong with your input data...</env:Text>
</env:Reason>
</env:Fault>
</env:Body>
</env:Envelope>
But I don't want to have a faultCode env:Receiver, I'd like to change it to env:Sender because the problem with input data is on client side ! But I don't know how to do. If I change faultCode to FaultCode.SENDER in my exception class, I get well a env:Sender faultCode but my customFaultCode is not considered and I get :
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header/>
<env:Body>
<env:Fault>
<env:Code>
<env:Value>env:Sender</env:Value>
</env:Code>
<env:Reason>
<env:Text xml:lang="en">WTF! Something wrong with your input data...</env:Text>
</env:Reason>
</env:Fault>
</env:Body>
</env:Envelope>
I saw in the javadoc of SimpleSoapExceptionResolver that the fault code is always set to Receiver (for SOAP 1.2). How can I change this ?
Stieuma