CXF-CXF未捕获自定义异常 [英] CXF - custom exception is not caught by CXF
问题描述
我正在使用CXF 2.3.3开发SOAP Web服务。我想在用户提交错误数据时引发自定义异常。我的异常类如下。
I am developing a SOAP web service with CXF 2.3.3. I want to throw a custom exception when user has submitted wrong data. My exception class looks like this.
@WebFault(name="InvalidUserDataException", targetNamespace="http://foo.bar.com/")
@XmlAccessorType(XmlAccessType.FIELD)
public class InvalidUserDataException extends RuntimeException {
public InvalidUserDataException(){
super();
}
String validationErrors;
}
在我的方法Impl类中,我故意抛出此异常以查看CXF是否将SoapFault异常返回给客户端,但是无论我对这些类中的任何一个执行什么操作,都会导致相同的错误:createNewUser抛出了异常,现在结束。
In my method Impl class I purposely throw this exception to see whether SoapFault exception is returned by CXF to client, but whatever I do to any of these classes results in same error: createNewUser has thrown exception, unwinding now.
请注意,WSUserRegistration接口还声明自己,createNewUser方法将引发InvalidUserDataException。
Note that WSUserRegistration interface also declares itself that createNewUser method throws InvalidUserDataException.
public class WSUserRegistrationImpl implements WSUserRegistration {
@Autowired
IWSUserValidationProxy validationProxyImpl;
@Override
public int createNewUser(RegistrationInputProperty registrationInfo) throws InvalidUserDataException {
if (true) {
throw new InvalidUserDataException();
}
return 1;
}
}
我的目标是从SOAPFaultOutInterceptor捕获此异常并返回自定义的faultDetail。
My goal is to catch this exception from a SOAPFaultOutInterceptor and return a customized faultDetail.
如何使CXF捕获此错误并返回SOAPFault对象?有任何想法吗?
How do I make CXF catch this error and return a SOAPFault object? Any ideas?
推荐答案
这将为您提供帮助。
http:// willemjiang .blogspot.com / 2011/01 / how-to-map-soap-fault-message-with.html
this would help you. http://willemjiang.blogspot.com/2011/01/how-to-map-soap-fault-message-with.html
这篇关于CXF-CXF未捕获自定义异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!