For our current adf project we’re generating webservice proxy clients against the wsdls of our OSB services.
In one of the services we had the next xsd construction :
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:complexType name="EmployeeType"> <xs:annotation> <xs:documentation xml:lang="nl">XML Represenation of the Employee domain object</xs:documentation> </xs:annotation> <xs:sequence> <xs:element name="id" type="xs:int" minOccurs="0"> <xs:annotation> <xs:appinfo> <jxb:property name="idElement" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"/> </xs:appinfo> </xs:annotation> </xs:element> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> <xs:element name="birthdate" type="xs:date"/> </xs:sequence> <xs:attribute name="id" type="xs:int"/> </xs:complexType> </xs:schema>
The object contains both an id-element and an id-attribute.
When trying to generate the Webservice proxy against the wsdl containing this definition, JDeveloper will generate the next error :
Error creating model from wsdl “file:/EmployeeService.wsdl”: The following location is relevant to the above errorProperty “Id” is already defined. Use
JAXB tries to generate the java representation of this schema and will (try to) generate a java class in which it will generate 2 variables with the name of ‘id’.
The wizard also comes with the solution on how we could implement the fix for this.
Change the schema to :
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" <b>xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"</b>> <xs:complexType name="EmployeeType"> <xs:annotation> <xs:documentation xml:lang="nl">XML Represenation of the Employee domain object</xs:documentation> </xs:annotation> <xs:sequence> <xs:element name="id" type="xs:int" minOccurs="0"> <xs:annotation><b> <xs:appinfo> <jaxb:property name="idElement"/> </xs:appinfo> </b> </xs:annotation> </xs:element> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> <xs:element name="birthdate" type="xs:date"/> </xs:sequence> <xs:attribute name="id" type="xs:int"/> </xs:complexType> </xs:schema>
We added a few things.
- add xmlns:jaxb=”http://java.sun.com/xml/ns/jaxb” jaxb:version=”2.0 to the schema-tag
- add the xs:appinfo-element (and childs) to the “xs:element name=”id” element
or make use of an external binding file
<jxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <jxb:bindings node=".//xs:element[@name='id']"> <jxb:property name="idElement"/> </jxb:bindings> </jxb:bindings>
With this property we can force jaxb to generate a variable idElement instead of the id-element. So no duplicates on variable-name will get generated.
This will result in the next java code fragment :
public class EmployeeType {
@XmlElement(name = "id")
protected BigInteger idElement;
protected String firstname;
protected String lastname;
protected XMLGregorianCalendar birthdate;
@XmlAttribute
protected BigInteger id;
No duplicates in variables, since it generated idElement and id.
Popularity: 4% [?]


