I'm currently writing a new set of web services using JAX-WS but I'm having difficulties deciding on the best way to validate the inputs. I can do some validation in my implementation classes but some input errors fail silently. For example character data in a numeric element will result in a null Integer in the JAXB object.
These are the designs I've come across.
@SchemaValidation
I could add this annotation to the endpoint class and JAX-WS will take care of the validation. This worked locally in tomcat but there are concerns that it won't work on some servers. My main gripe is that I have to surrender control of how the errors are output in the response.All inputs as strings
I hate this approach but I've seen other web services where all inputs are defined as strings. This would catch the case of character data in a numeric element as I could check it where I call our API although you'd still miss any incorrectly named xml elements.
I really want the errors to come back in the same manner as the API errors rather than as a soap fault. Any ideas? I've seen a few sites talking about intercepting the request with a kind of filter. Not sure how this would work with different responses for different operations though.
E.G.
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<myOperationResponse>
<return>
<success>false</success>
<errors>
<error>
<code>UNIQUECODE</code>
<message>Message text</message>
</error>
</errors>
</return>
</myOperationResponse>
</S:Body>
</S:Envelope>
Maybe I'm asking too much but thought I'd see if I'd missed anything. TIA.