Reputation: 123
I have a Spring webservice which throws a custom exception for any error scenerio. I have configured the exception class like this:
@SoapFault(faultCode = FaultCode.CUSTOM, customFaultCode="{http://com/examples/webservice/utils/AppConstants}"+AppConstants.FAULT_CODE)
public class ConfigurationException extends Exception {/**Codes**/}
Throwing exception as below:
throw new ConfigurationException("Validation exception");
and in Spring config xml I have added this:
<bean class="org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver"/>
It is working fine if I call this service from SOAPUI. I'm getting proper SOAP fault with faultcode and faultString.
But, when I'm invoking the service from java spring client. I'm getting SOAP fault as exception.My requirement is to get SOAP fault message object so that I can get the faultCode and faultString.
Thanks in advance for any help in this regard.
Upvotes: 1
Views: 2792
Reputation: 43117
You can catch the fault in the client code, and in the catch block retrieve the fault code and string with exception.getFaultCode() and exception.getFaultString(), have a look at the javadoc for further details.
Upvotes: 0