Search code examples
javaspringsoapspring-ws

Catch EndpointNotFound in Spring WS


How catch NoEndpointFoundException in Spring WS?

By default MessageDispatcher.dispath() throws NoEndpointFoundException in case of absence appropriate Endpoint but then WebServiceMessageReceiverObjectSupport.handleConnection() just hides the exception. In my point I should catch it by myself.

Is it good idea to add custom EndpointMapping via MessageDispatcher.getEndpointMappings().add() and throws exception in that?


Solution

  • I find out following solution:

    @Component
    @Order(Ordered.LOWEST_PRECEDENCE)
    public class NoEndpointFoundEndpointMapping implements EndpointMapping {
    
        @Override
        public EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception {
    
            throw new MyCustomException(...);
        }
    }