We generate java with wsdl2java from a third-party WSDL (this means that we cannot change it). WSDLs contain:
<wsdl:import namespace="http://somenamespace" location="xsdschema.xsd" />
This xsdschema contains elements with nillable = "true" and conflicts (duplicates) of the generator reports in ObjectFactory. We are trying to use binding generateElementProperty = "false". But in the binding definition that is defined for WSDL, the generator ignores it, and when defining the bindings for xsd, WSDL2Java says that XSD is not part of the compilation. How to solve it?
XJB for WSDL (generateElementProperty is ignored - duplication error in ObjectFactory):
<jaxws:bindings version="2.0"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
wsdlLocation="wsdl3rd.wsdl">
<jaxb:bindings>
<jaxb:globalBindings generateElementProperty="false"/>
</jaxb:bindings>
</jaxws:bindings>
XJB for XSD (error: XSD is not part of the compilation):
<jxb:bindings version="2.1" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:bindings schemaLocation="xsdschema.xsd">
<jxb:bindings>
<jxb:globalBindings generateElementProperty="false"/>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
Maven:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<wsdlRoot>src/main/resources/wsdl</wsdlRoot>
<defaultOptions>
<bindingFiles>bindingFile>bindingFile.xjb</bindingFile>
</bindingFiles>
</defaultOptions>
</configuration>
</execution>
</executions>
</plugin>