Issue
We are attempting to generate Java classes from this wsdl file: http://ws.infotorg.no/xml/NE/EDROnline/2017-01-23/EDROnline.wsdl.
To do generate the code we use maven
as a build tool, where we have specified the following build plugin:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.5.3</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>3.5.3</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/src</sourceRoot>
<wsdlOptions>
<wsdlOption>
<extraargs>
<extraarg>-verbose</extraarg>
<extraarg>-autoNameResolution</extraarg>
</extraargs>
<wsdl>${basedir}/src/main/resources/wsdl/EDROnline.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/EDROnline.wsdl</wsdlLocation>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/bindings.xml</bindingFile>
</bindingFiles>
</wsdlOption>
</wsdlOptions>
</configuration>
</execution>
</executions>
</plugin>
We run mvn clean package
to execute the build.
We obtain the following errors:
- https://ws.infotorg.no/xml/EVRY/InfotorgForetak/2015-12-01/include/ResultatregnskapOgBalanse.xsd [0,0]: Property "Aar" is already defined. Use <jaxb:property> to resolve this conflict.
- https://ws.infotorg.no/xml/EurotaxGlass/Bruktbilverdi/2016-03-09/Bruktbilverdi.xsd [0,0]: Property "Error" is already defined. Use <jaxb:property> to resolve this conflict.
We see in the following stackoverflow answer: XSD "property already defined" that these errors can be fixed by simply renaming said properties to something else, and the renaming can be specified using a bindings file. We inspect the
.xsd
files to figure out the XPath.
Solution for error 1: The first error was simple, in our bindings file fixed the error by specfiying:
<jaxb:bindings schemaLocation="https://ws.infotorg.no/xml/EVRY/InfotorgForetak/2015-12-01/include/ResultatregnskapOgBalanse.xsd" node="/xs:schema">
<jaxb:bindings node="//xs:element[@name='Aar']">
<jaxb:property name="ResultatregnskapOgBalanseAar" />
</jaxb:bindings>
</jaxb:bindings>
Attempted solution for error 2: In the xsd file of the second error we could not find any properties named "Error". However there were three properties with the name "error". We try to resolve those:
<jaxb:bindings schemaLocation="https://ws.infotorg.no/xml/EurotaxGlass/Bruktbilverdi/2016-03-09/Bruktbilverdi.xsd" node="/xs:schema">
<jaxb:bindings node="//xs:complexType[@name='error']">
<jaxb:property name="BruktbilverdiComplexTypeError" />
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='error']">
<jaxb:property name="BruktbilverdiElementError" />
</jaxb:bindings>
<jaxb:bindings node="//xs:attribute[@name='error']">
<jaxb:property name="BruktbilverdiAttributeError" />
</jaxb:bindings>
</jaxb:bindings>
Thus the whole bindings file is:
<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxb:bindings schemaLocation="https://ws.infotorg.no/xml/EVRY/InfotorgForetak/2015-12-01/include/ResultatregnskapOgBalanse.xsd" node="/xs:schema">
<jaxb:bindings node="//xs:element[@name='Aar']">
<jaxb:property name="ResultatregnskapOgBalanseAar" />
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="https://ws.infotorg.no/xml/EurotaxGlass/Bruktbilverdi/2016-03-09/Bruktbilverdi.xsd" node="/xs:schema">
<jaxb:bindings node="//xs:complexType[@name='error']">
<jaxb:property name="BruktbilverdiComplexTypeError" />
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='error']">
<jaxb:property name="BruktbilverdiElementError" />
</jaxb:bindings>
<jaxb:bindings node="//xs:attribute[@name='error']">
<jaxb:property name="BruktbilverdiAttributeError" />
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
And we still obtain the same second error. We have obtained every .xsd
file that is imported and search through every one of them, and none of them as anything called "Error".
What we want
Solve error 2
Solution
I managed to fix the error. Using a program called SoapUI I managed to download all the "dependencies" of the WSDL file. In a directory with all said files I use grep -r error .
to search for all files containing "error". It found two files:
- Bruktbilverdi.xsd:
targetNamespace=http://ws.infotorg.no/xml/EurotaxGlass/Bruktbilverdi/2012-08-27/Bruktbilverdi.xsd
- Bruktbilverdi_1.xsd:
targetNamespace=http://ws.infotorg.no/xml/EurotaxGlass/Bruktbilverdi/2016-03-09/Bruktbilverdi.xsd
The files has similar content, I am not sure why both are listed as dependencies (there were many nested levels of imports, it is hard to keep track)
Anyways, I added another specification to rename for the other file as well to the bindings file, resulting in:
<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxb:bindings schemaLocation="https://ws.infotorg.no/xml/EVRY/InfotorgForetak/2015-12-01/include/ResultatregnskapOgBalanse.xsd" node="/xs:schema">
<jaxb:bindings node="//xs:element[@name='Aar']">
<jaxb:property name="ResultatregnskapOgBalanseAar" />
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="https://ws.infotorg.no/xml/EurotaxGlass/Bruktbilverdi/2016-03-09/Bruktbilverdi.xsd" node="/xs:schema">
<jaxb:bindings node="//xs:element[@name='error']">
<jaxb:property name="Bruktbilverdi2016ElementError" />
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="https://ws.infotorg.no/xml/EurotaxGlass/Bruktbilverdi/2012-08-27/Bruktbilverdi.xsd" node="/xs:schema">
<jaxb:bindings node="//xs:element[@name='error']">
<jaxb:property name="Bruktbilverdi2012ElementError" />
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
which resolved the error. Altough I still find it odd that the error message states "Error" with capital E, but I could only find properties with a smal case "e"
Answered By - Naphat Amundsen
Answer Checked By - Mary Flores (JavaFixing Volunteer)