Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8538

maven cxf-xjc-plugin ignores xjc:simple in binding file for nested objects

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.3.1
    • Fix Version/s: None
    • Component/s: JAXB Databinding
    • Environment:

      OS: Linux linux-mint-desktop 5.8.0-53-generic
      Java: openjdk 11.0.11 2021-04-20 (using java 1.8 compatibility)
      Maven: 3.6.3

    • Estimated Complexity:
      Unknown

      Description

      I'm working on a project which requires creating xml files that conforms to an xsd schema and subsequently send these files using a SOAP service client.
      To create java objects from the .xsd i'm using this configuration in pom.xml

      <plugins>
      ...
      <plugin>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-xjc-plugin</artifactId>
      <version>3.3.1</version>
      <executions>
      <execution>
      <id>generate-sources</id>
      <phase>generate-sources</phase>
      <goals>
      <goal>xsdtojava</goal>
      </goals>
      <configuration>
      <additionalJvmArgs>-Djavax.xml.accessExternalDTD=all</additionalJvmArgs>
      <sourceRoot>${basedir}/src-gen/main/java</sourceRoot>
      <xsdOptions>
      <xsdOption>
      <xsd>${basedir}/src/main/resources/wsdls/Schema.xsd</xsd>
      <extension>true</extension>
      <bindingFile>${basedir}/src/main/resources/cxf-bindings.xml</bindingFile>
      </xsdOption>
      </xsdOptions>
      </configuration>
      </execution>
      </executions>
      </plugin>
      ...
      </plugins>

      and my cxf-bindings.xml has this content:

      <jaxb:bindings jaxb:version="2.0"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
      xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
      jaxb:extensionBindingPrefixes="xjc">
      <jaxb:globalBindings generateElementProperty="false">
      <jaxb:serializable uid="1"/>
      <xjc:javaType name="java.time.LocalDateTime" xmlType="xs:dateTime" adapter="it.quantum.fatture.utils.XmlDateTimeConverter"/>
      <xjc:javaType name="java.time.LocalDate" xmlType="xs:date" adapter="it.quantum.fatture.utils.XmlDateConverter"/>
      <xjc:simple/>
      </jaxb:globalBindings>
      </jaxb:bindings>

      In the generated classes on the root element the extension <xjc:simple> is applied (the 'Type' suffix has been removed and a list member has the plural name 'invoiceBodies') but for nested complex types this seems to not have any effect (all the classes have names like 'InvoiceHeaderType', 'InvoiceBodyType' and so on and list members have the singular name).
      Am i doing something wrong and maybe there is some configuration i am missing to recursively apply xjc:simple to all nested complex types?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              darioarena87 Dario Arena
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: