2017-02-13 59 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(...); 
    } 
}