I am successfully generating java classes from multiple wsdl endpoints using maven-jaxb2-plugin.
This is one execution:
<execution>
<id>generateDelta</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>com.somepackage1</generatePackage>
<schemas>
<schema>
<url>
wsdl_url
</url>
</schema>
</schemas>
</configuration>
</execution>
The issue here is that I have multiple executions, thus generating multiple class, each execution saving the classes in different package.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Bapiret2", propOrder = {...})
One of the class Babiret2.java is generated in more then one package (so, it comes from multiple wdsls)
When I execute code that uses this stubs, in a unit test for example I get the following exception:
org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{urn:sap-com:document:sap:soap:functions:mc-style}Bapiret2". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at com.somepackage1.Bapiret2
this problem is related to the following location:
at com.somepackage2.Bapiret2
I found some possible fixes like adding in configuration under args tag
-XautoNameResolution
arg, it did not worked
I tested if changing the XmlType name attribute works and it does. Also adding namespace to XmlType works.
The problem is that I do not know how to add this with maven when generating the classes