2017-02-13 73 views
0

如何在WS中捕获NoEndpointFoundException春季捕获端点未发现WS

默认情况下,MessageDispatcher.dispath()在没有适当的端点时抛出NoEndpointFoundException,但是然后WebServiceMessageReceiverObjectSupport.handleConnection()只是隐藏了异常。在我看来,我应该自己去抓。

通过MessageDispatcher.getEndpointMappings().add()添加自定义EndpointMapping并引发异常是个好主意吗?

回答

0

我发现以下解决方案:

@Component 
@Order(Ordered.LOWEST_PRECEDENCE) 
public class NoEndpointFoundEndpointMapping implements EndpointMapping { 

    @Override 
    public EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception { 

     throw new MyCustomException(...); 
    } 
}