2 Replies Latest reply on Oct 3, 2007 9:29 AM by JBossUser

    Passing constraints from POJO to XML Schema

    JBossUser Newbie

      Environment:
      JBoss-4.2.1.GA
      Jbossws-native-2.0.1.GA
      JDK 1.5

      Description:

      When I deploy JAX-WS web service, JBoss generates appropriate xml schema along with WSDL, which is great. I am trying to find out how should the field level constraints be specified in POJO so they get propogated to the generated xml schema (for example: minLength, maxLength etc.).

      Any suggestions?
      Thanks

        • 1. Re: Passing constraints from POJO to XML Schema
          Magesh Bojan Master

          JBossWS uses JAXB for marshalling and unmarshalling WS requests. As of now there is no provision to generate these validations through annotations in JAXB. However JAXB has a validator process which is currently not yet implemented in any implementations of JAXB. More info on JAXB validation process only when unmarshalling is here http://java.sun.com/webservices/docs/1.5/tutorial/doc/JAXBWorks2.html

          "When a schema is compiled into a JAXB2 object, the relevant information is added as annotations. This is much faster than processing the schema file, and still offers decent validation. If you want extra strict validation, then JAXB2 does offer the ability to hook into a JAXP validator, but this has a significant performance cost. For this reason the JAX-WS reference implementation does not make use of that feature. The JAXB2 spec specifies an optional fail-fast validation that is more efficient, although there are currently no implementations that use this."

          We also have an outstanding feature request here for validating schemas for incoming request. Please feel free to vote and watch for it here http://jira.jboss.org/jira/browse/JBWS-1172

          But on the whole these annotations and validations are JAXB specifics and you will need to request any implementors like the SUN RI here https://jaxb.dev.java.net/

          • 2. Re: Passing constraints from POJO to XML Schema
            JBossUser Newbie

            Thanks for the response. I will look into other options that you mentioned.