Spring web services payloadvalidatinginterceptor
May 14, 2011 PM org.soap.server.endpoint.interceptor. Abstract Fault Creating Validating Interceptor handle Request Validation Errors WARNING: XML validation error on request: cvc-complex-type.2.4.b: The content of element 'Contact' is not complete. I’d rather have the server tell the client what the error was so I can spend my time writing code, not looking at log files.
Communicating Errors to the Client But if we want to communicate errors back to our client, we need to make a spot for error messages in the XSD so we can send back errors that validate against the XSD.
Handling XSD Validation Errors Let’s pretend we have a new customer signed on for our contact service, and their client code has a bug in it that so that the Phone element isn’t added to a contact.
/** * Interceptor that can return an error for XML that * doesn't validate.
We’ve communicated to the client that there was an error with their request XML, and a phone number was missing.
This approach will handle your XSD validation errors, but for the message to even be checked for correctness, it must be valid XML.
It follows Postel’s robustness principle – “be conservative in what you send, liberal in what you accept” – and that’s probably OK for such a simple service.
But for something more complex, you might consider Mark Rose’s rebuttal to the robustness principle, and impose more restrictions.
Unsupported Encoding Exception; import java.security.