Hi,

I see the following cases when BeanValidation is preferable to schema validation:

1.) if the error should be clearly associated to the property which caused the error. This is possible with beanvalidation using the propertypath, with xml schema validation error messages you usually get the reference to the type but not the field which caused the error.

(e.g. cvc-pattern-valid: Value ''{0}'' is not facet-valid with respect to pattern ''{1}'' for type ''{2}''.)

2.) if the error message should be human readable / presented to the end user

3.) if the schema validation causes memory troubles e.g. with bigger xml requests with binary data in it (although this should be rarely the case with SAXParsers)

IMHO especially in case 1+2 it would be nice to use the beanvalidation, especially if the rest api is directly tied to a ui.

Best regards,
Johannes


Am 23.08.2016 um 23:21 schrieb Sergey Beryozkin:
Hi

I'm not sure I'm understanding why is it needed.

If we have a WADL-first approach which is where wadl-to-java becomes useful, one can properly design XML schema (have all the restrictions specified as needed). Then import this schema as a WADL grammar to generate the JAXB beans and then use the same schema to enforce the JAXB-level schema validation which will work on the client and on the server sides.

FYI, you can configure CXF JAXBElementProvider with XML schema references.

Cheers, Sergey

On 23/08/16 18:03, J. Fiala wrote:
Hi,

CXF supports bean validation, however wadl2java doesn't support any bean
validation annotations yet (see
https://github.com/krasa/krasa-jaxb-tools for the implementation for
complex parameters).

As it is not allowed to add @Valid to the method signatures of the
implementation classes, the @Valid annotation needs to be added to the
interface (which is generated using wadl2java).

Are there any plans to add @Valid-support to wadl2java (for methods +
complex parameters)?

Best regards,
Johannes




Reply via email to