For a REST-Webservice i had to validate incoming Data. Is is possible to 开发者_Go百科validate incoming data with an Entity Class and JAXB , instead of xsd
Below is a link of how you could validate Data in a JAX-RS service using JAXB validation based on a schema:
- Validate JAXBElement in JPA/JAX-RS Web Service
If you don't have an XML schema from your model, then you could use JAXB to generate one:
- http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JAXB/GenerateSchema
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
.
精彩评论