Hi. We use CXF via Spring as the JAX-WS impl and configured JAXB on the jaxws:client for databinding :
<jaxws:dataBinding> <bean class="org.apache.cxf.jaxb.JAXBDataBinding"/> </jaxws:dataBinding> We have a problem in which the outbound request XML that is generated is reported schema invalid (while the contents is valid according to the schema on disk). After some investigation we found out that systems working with an older version of JAXB reported the validation error while systems having a newer version did not. After digging into the code, we found that actual XML schema used for validation is not loaded from classpath/disk buts generated by JAXB on the fly from its own JAXB context: In org.apache.cxf.jaxb.JAXBDataBinding: List<DOMResult> generateJaxbSchemas() throws IOException { return JAXBUtils.generateJaxbSchemas(context, BUILT_IN_SCHEMAS); } Which eventually calls: context.generateSchema(new SchemaOutputResolver() {} After inspection of the schema DOM we see that in case of an element having minOcurrs=0 and nillable=true at the same time (in the original schema on disk), the older JAXB strips the minOccurs when generating the schema DOM (don't know why) while the newer does not. If the nillable is removed altogether, the minOcurrs remains in both versions. So when JAXB strips the minOccurs in the first case, the data is no longer schema valid, at least when validating agains the in-mem schema, as the element is no longer optional. My questions: while this seems to be a JAXB issue (which has apparently already been addressed in newer versions) , I would like to k now the reason that CXF generates the schema in this way instead of loading it from classpath or disk? And secondly, is there a way to completely bypass the on-the-fly schema generation and point to locations on a file system for example so it uses the actual schema? Like building a map with NS/schemaLocation? Thanks!