I am generating Java classes using a WSDL file that imports and includes a whole slew of other schemas and DTDs, which in turn reference each other. (It is the infamous 'standard' XTA2 V3 WSDL file, to name names. Standard in quotes because one would assume that a standard WSDL file can be generated with standard tools without requiring patches.)
The error messages I get look like this:
[ERROR] 'NonEmptyStringType' is already defined
Zeile 17 von file:/C:/Users/itbc000257/Documents/projekte/km-tafe/src/main/resources/META-INF/wsdl/OSCI_MessageMetaData_V2.02.xsd
[ERROR] (related to above error) the first definition appears here
Zeile 12 von file:/C:/Users/itbc000257/Documents/projekte/km-tafe/src/main/resources/META-INF/wsdl/OSCI_MessageMetaData_V2.02.xsd
The error was caused by schema imports where one schema referenced the
schemaLocation
with a relative path, whereas the others use an absolute http URL.OSCI2_02.xsd uses a relative
schemaLocation
:XTA.wsdl, XTA-synchron.wsdl, XTA-Webservice-Datentypen.xsd, XTA-Webservice-Globale-Elemente.xsd use an absolute
schemaLocation
URL:There is a long-standing bug in xjc from the jaxb-ri which mishandles this problem, and a proposed fix by the late Highsource, which never made it into the product.
In my case, the workaround was to download all related schemas, patch the OSCI2_02.xsd schema import to use the absolute URL and create a jax-ws-catalog.xml, so that wsimport uses my patched schema rather than downloading the broken file from the Internet.
Find my setup below.
WSDL recursive download for schema files:
The script doesn't download DTDs, so I also had to download:
All downloaded files go into src/main/resources/META-INF/wsdl.
The following jax-ws-catalog.xml file in the same folder tells wsimport to look for the downloaded files rather than downloading them from the Internet:
Here my jaxws-maven-plugin definition which uses the jakarta-ee edition of the plugin (suitable above Java 8), together with the patrodyne hisrc-basicjaxb-plugins for jakarta-ee XML for generation of toString, etc.:
And finally, the generated classes need jakarta.xml dependencies: