'Spring WS - Use PayloadValidatingInterceptor to validate a single SOAP Web Service

I have a project that exposes several SOAP endpoints. I want to use PayloadValiditatingInterceptor provided by Spring WS to validate only a particular end-point. However, my current implementation is applying validation to each and every SOAP endpoint.

The source code is as follows:

@Bean(name = "requestMessage")
public SimpleXsdSchema requestMessage()
{
    return new SimpleXsdSchema(new ClassPathResource("com/schemas/2_0/requestMessage.xsd"));
}

@Override
public void addInterceptors(List<EndpointInterceptor> interceptors)
{
    PayloadValidatingInterceptor validatingInterceptor = new PayloadValidatingInterceptor();
    validatingInterceptor.setValidateRequest(true);
    validatingInterceptor.setXsdSchema(requestMessage());
    interceptors.add(validatingInterceptor);
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source