如何在 Spring WS 中捕获 NoEndpointFoundException
?
默认情况下,如果缺少适当的端点,MessageDispatcher.dispath()
会抛出NoEndpointFoundException
,但随后WebServiceMessageReceiverObjectSupport.handleConnection()
只是隐藏异常。就我而言,我应该自己捕获它。
通过 MessageDispatcher.getEndpointMappings().add()
添加自定义 EndpointMapping 并抛出异常是个好主意吗?
最佳答案
我找到了以下解决方案:
@Component
@Order(Ordered.LOWEST_PRECEDENCE)
public class NoEndpointFoundEndpointMapping implements EndpointMapping {
@Override
public EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception {
throw new MyCustomException(...);
}
}
关于java - 在 Spring WS 中捕获 EndpointNotFound,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42203090/