Is there a way to inlcude @Pattern and @Size JSR 303 annotations to cxf-generated JAXB classes and perform schema validation on them ?

Solution Verified - Updated -

Issue

  • The @org.apache.cxf.annotations.SchemaValidation in cxf only performs simple validations such as @XmlElement(required = true)
  • The following below JAXB JSR 303 annotations are not validated when including them manually in the JAXB classes generated from the code,
@XmlElement(required = true)
    private String schoolCode;
    @XmlElement(required = true)
    @Pattern(regexp = "^[A-Z]+.*")
    @Size(min = 1, max = 80)    
    private String schoolName;
  • When manually writing these validations using restrictions in wsdl file in the nested xsd or an external xsd, its working fine, but using bottom up approach, including annotaions in java pojo class does not work.

  • How to achieve the below restrictions that was used in wsdl in java pojo class and also that to be validated by JBossWS-CXF using the @org.apache.cxf.annotations.SchemaValidation if possible.

<xs:simpleType name="string2000">
    <xs:restriction base="xs:string">
        <xs:maxLength value="2000"/>
        <xs:minLength value="1"/>
        <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}-[ \t\r\n]][\p{IsBasicLatin}\p{IsLatin-1Supplement}-[\t\r\n]]*"/>
    </xs:restriction>
</xs:simpleType>

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 6.0.0
    • 6.0.1
  • JBossWS-CXF

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content