5.5.2.2. PayloadValidatingInterceptor
One of the benefits of using a contract-first development style is that we can use the schema to validate incoming and outgoing XML messages. Spring-WS facilitates this with the PayloadValidatingInterceptor. This interceptor requires a reference to one or more W3C XML or RELAX NG schemas, and can be set to validate requests or responses, or both.
Note that request validation may sound like a good idea, but makes the resulting Web service very strict. Usually, it is not really important whether the request validates, only if the endpoint can get sufficient information to fullfill a request. Validating the response is a good idea, because the endpoint should adhere to its schema. Remember Postel's Law: “Be conservative in what you do; be liberal in what you accept from others.”
И при этом:
public abstract class AbstractValidatingInterceptor extends TransformerObjectSupport
implements EndpointInterceptor, InitializingBean {
private boolean validateRequest = true;
private boolean validateResponse = false;
...
}
В спринговой команде чувствуются разногласия :)