I\'m building a web service using Spring Boot (1.2.4.RELEASE) and I\'m quite new to this framework. Especially, I\'m trying to customize the SoapFault content when a
I know that this response is outdated but maybe it works for someone else.
MessageDispatcher raise two Resolvers by default: SimpleSoapExceptionResolver and SoapFaultAnnotationExceptionResolver in that order, if you want to get a soap fault with custom code and error message, you must declare the correct order to get SoapFaultAnnotationExceptionResolver first, and then SimpleSoapExceptionResolver.
Step 1. On bean configuration file corresponding:
Step 2. Declare your Exceptions as follows:
@SoapFault(faultCode = FaultCode.CUSTOM,locale="en",faultStringOrReason = "CUSTOM_MESSAGE",customFaultCode="YOUR_NAMESPACE + YOUR_CUSTOM_CODE")
public class DeclaracionNotFoundException extends BusinessException {
public DeclaracionNotFoundException(){
super();
}
public DeclaracionNotFoundException(String message) {
super(message);
}
}
Step 3.
Raise your Exception in your code normally
throws new DeclaracionNotFoundException(); //With default message from faultStringOrReason or throws new DeclaracionNotFoundException("Ops!!!"); //With other message
It works for me, and I got the following:
ns0:4
Ops !!!
I defined faultCode = 4 and faultString=Ops !!!
Regards