users@jax-ws.java.net

JAXB xsi:type problem

From: Ingo Siebert <ingo.siebert_at_cas.de>
Date: Thu, 20 Jul 2006 11:15:10 +0200

Hi,

i hope someone here can help me.

I get a JAXB2 class cast exception in the second line. The
creatObject-method has to return an Appointment, not the superclass
DataObject.

DataObject dataObject = service.createObject(APPOINTMENT);
Appointment appointment = (Appointment) dataObject;

My WSDL says, that an Appointment is a "sub-type" of DataObject. That's
why the class Appointment extends DataObject. JAXB2/XJC created the
class correctly. The WSDL contains:

<xsd:complexType name="Appointment">
   <xsd:complexContent>
     <xsd:extension base="eimschemaataObject"> [...]

But why does JAXB2 create an DataObject instead of an Appointment at
run-time?
The XML specifies the class by the XSI:TYPE attribute.

Axis 1 as client ws technology is doing it correctly.

That's the xml message:

<ns2:createObjectResponse xmlns:ns2="http://schema.eim.de"
xmlns:ns3="http://faults.eim.de">
   <ns2ataObject xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="ns2:Appointment">
     <ns2:id xsi:nil="true"/>
     <ns2:keyword xsi:nil="true"/>
     <ns2:startDate xsi:nil="true"/>
     <ns2:endDate xsi:nil="true"/>
   </ns2ataObject>
</ns2:createObjectResponse>

I tested it with JAXB2 final an the nightly build.

Cheers,

Ingo
-- 
CRM Products Development - New Technologies
CAS Software AG
Well informed. Always and everywhere.
www.cas.de