users@jaxb.java.net

The runtime type of IDREF types

From: Tavor <tavor.haim_at_amdocs.com>
Date: Wed, 23 Mar 2011 09:05:13 -0700 (PDT)

Hi,

I have a WSDL with types utilizing the ID/IDREF mechanism and I'm trying to
generate a WS consumer Java code (using wsimport of JDK 1.6) .
I expect the consumer to return the complete types (resolved and without ID
references).


Here is my problem:

In my WSDL some types are of type IDREF, for example:

<xs:element maxOccurs="unbounded" minOccurs="0" name="customers"
nillable="true" type="xs:IDREF">
  <xsd:annotation>
    <xsd:appinfo>
      <jaxb:property xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
        <jaxb:baseType name="Customer1"/>
      </jaxb:property>
    </xsd:appinfo>
  </xsd:annotation>
</xs:element>

In the generated code, the following was generated:

    @XmlElementRef(name = "customers", type = JAXBElement.class)
    protected List<Customer1> customers;

In runtime, when I try to access the "customers" field, I get the following
exception:
Exception in thread "main" java.lang.ClassCastException:
javax.xml.bind.JAXBElement cannot be cast to v1.customer.Customer1

I tried several ways to work around it, but the only one that worled was to
replace:
    @XmlElementRef(name = "customers", type = JAXBElement.class)
with:
    @XmlIDREF

Althogh it works, I want it to be fully automated without me having to
manually modified the generated code.

Any idea why JAX-WS set the type as "JAXBElement.class"?
Any idea how to resolve it?

Thanks,
Tavor
-- 
View this message in context: http://old.nabble.com/The-runtime-type-of-IDREF-types-tp31221222p31221222.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.