JAX-WS request validation using JAXB
It is a good practice to validate the incoming request xml as is the case with every MVC system. (MVC might not fit here but in principle, its same just that the view is XML). If the mentioned annotation (@SchemaValidation
) is not supported, then one way out is is use handler which will validate the incoming request using JAXB Validation.
PrasadB
Updated on June 14, 2022Comments
-
PrasadB almost 2 years
In JAX-WS, to validate the incoming request, one of the ways is to use @SchemaValidation as suggested in below link.
However the application server (WAS 7) I am using does not yet support @SchemaValidation. (Please correct me if WAS 7 does support this annotation)
So I am looking at other options like implementing a handler to validate the incoming request. Either in the handler or the endpoint class itself, I can create the JAXBContext and use the JAXB validator. Do I need to create the JAXBContext explicitly or is it available as a resource / annotation since JAX-WS internally uses JAXB? Is this a good way to implement validation in JAX-WS? (In the absence of @SchemaValidation validation)
Is it a standard practice to validate the incoming request xml in web services or is it given a skip due to performance hit it might take?
-
PrasadB over 12 yearsThanks Santosh. I have implemented handler to validate the incoming request. The following link was very helpful link.
-
PrasadB over 12 yearsThanks Archimedis. I will check if DataPower is an option in our organization. Also, I thought @SchemaValidation is part of JAX-WS standard and not vendor specific. I have used a JAX-WS handler to validate as I need to validate the incoming xml before unmarshalling to Java objects
-
Santosh over 12 yearsNice link indeed. Thanks for sharing.
-
Archimedes Trajano over 12 yearsI had an old implementation that does use JAX-WS handlers, but I found it to be SOAP specific so I decided to try out interceptors instead since it does not need to be SOAP specific.
-
secario almost 9 yearslink is broken now =(
-
Pino about 4 yearsThe link posted by PrasadB is now dzone.com/articles/jax-ws-payload-validation-and