cxfjax-wsjax-ws-customization

XSD Restrictions for bottom-up JAX-WS


We are using Spring and CXF to provide SOAP Web Services. The WSDL is being generated from Java Code.

Is there a way to define validation rules in Java code that would be applied to generated XSD?

For example, support for some of JSR 303 annotations would be great. In such case this code:

@Pattern(regexp = "[0-9]+/[0-9]+")
private String phone;

would evaluate to such XSD:

<restriction base="string">
   <pattern value="[0-9]+/[0-9]+"></pattern>
</restriction>

Solution

  • I was looking for such JAXB extension: https://github.com/whummer/jaxb-facets

    Unfortunately, it's not an extension to JAXB but a fork, so it completely replaces JAXB implementation from JDK.

    The intention of this project was to be integrated into JDK, but it did not happen as you can see in this ticket: https://github.com/javaee/jaxb-v2/issues/917

    There is also another project addressing a similar issue: https://github.com/krasa/krasa-jaxb-tools, but this one is also not supported anymore.