JAX-WS request validation using JAXB

11,567

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.

Share:
11,567
PrasadB
Author by

PrasadB

Updated on June 14, 2022

Comments

  • PrasadB
    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.

    JAX-WS and XSD Validation

    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
    PrasadB over 12 years
    Thanks Santosh. I have implemented handler to validate the incoming request. The following link was very helpful link.
  • PrasadB
    PrasadB over 12 years
    Thanks 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
    Santosh over 12 years
    Nice link indeed. Thanks for sharing.
  • Archimedes Trajano
    Archimedes Trajano over 12 years
    I 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
    secario almost 9 years
    link is broken now =(
  • Pino
    Pino about 4 years
    The link posted by PrasadB is now dzone.com/articles/jax-ws-payload-validation-and