SoapFaultMappingExceptionResolver never gets hit with regular java exception

半世苍凉 提交于 2019-12-04 10:59:49

I got it working by adding

<property name="order" value="1"></property>

to the

<bean id="exceptionResolver" class="com.openclass.adapter.ws.resolvers.LisSoapFaultTranslatorExceptionResolver">

I think you should, in your exception resolver, override the method getFaultDefinition, something like this (Assuming your resolver is extending AbstractSoapFaultDefinitionExceptionResolver):

@Override
protected SoapFaultDefinition getFaultDefinition(Object endpoint, Exception ex) {
    if(ex instanceof LoginException){
        SoapFaultDefinition result = new SoapFaultDefinition();
        result.setFaultCode(QName.valueOf("SERVER"));
        return result;
    }
    return null;
}

And if you want your fault message (Exception) more customized, you should annotate it like:

@SoapFault(faultCode = FaultCode.SERVER)
public class LoginException extends Exception{}
Eria

I encountered a similar problem. I solved it replacing the bean name/id "exceptionResolver" by "soapFaultAnnotationExceptionResolver".

See: Adding detail in a WS SoapFault : my custom ExceptionResolver is not used

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!