Search code examples
validationrestjaxbjaxb2

JAXB and Entity Class validation


For a REST-Webservice i had to validate incoming Data. Is is possible to validate incoming data with an Entity Class and JAXB , instead of xsd


Solution

  • Below is a link of how you could validate Data in a JAX-RS service using JAXB validation based on a schema:

    If you don't have an XML schema from your model, then you could use JAXB to generate one:

    If you wanted to do validation without an XML schema you could use something like Bean Validation (JSR-303). With this you would still need to implement a custom MessageBodyReader/MessageBodyWriter.