I have two WSDLs from which I generate Java code using maven cxf-codegen-plugin (org.apache.cxf). Both of them use the same namespace and contains complex types of the same name which was reason why I experienced issues with conflicting java class names. I decided to solve it using bindings.xml:
<jaxws:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns="http://www.w3.org/2001/XMLSchema"
version="2.1">
<jaxws:bindings wsdlLocation="./TaskService_v1.wsdl" node="xsd:schema">
<jaxb:schemaBindings>
<jaxb:nameXmlTransform>
<jaxb:typeName prefix="TaskService" />
<jaxb:elementName prefix="TaskService" />
</jaxb:nameXmlTransform>
</jaxb:schemaBindings>
</jaxws:bindings>
</jaxws:bindings>
This renamed for example generated class B2BParameter to TaskServiceB2BParameter so I stopped getting conflicting names issues but I ran into another issue:
Unknown JAXB exception; nested exception is com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 4 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://serviceinterface.b2b.adx.com}B2BParameter". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at com.adx.b2b.serviceinterface.TaskServiceB2BParameter
this problem is related to the following location:
at com.adx.b2b.serviceinterface.B2BParameter
at protected java.util.List com.adx.b2b.serviceinterface.B2BRequest.parameter
at com.adx.b2b.serviceinterface.B2BRequest
...
This is generated TaskServiceB2BParameter.java:
package com.axd.b2b.serviceinterface_v1;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "B2BParameter", propOrder = {
"name",
"value"
})
public class TaskServiceB2BParameter {
...
}
How can update my bindings.xml to change @XmlType.name appropriately? Or do I really need to change target package? Thank you in advance!