views:

43

answers:

0

I have a following setup

Two objects:

ObjectB extends ObjectA

A webservice with a method: getObject(ObjectA obj)

In wsdl these objects defined like:

<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"  
targetNamespace="http://mypackage.com/xsd"&gt; 
<xs:complexType name="ObjectA"> 
<xs:sequence> 
<xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/> 
</xs:sequence> 
</xs:complexType> 
<xs:complexType name="ObjectB"> 
<xs:complexContent> 
<xs:extension base="ax21:ObjectA"> 
<xs:sequence> 
<xs:element minOccurs="0" name="phone" nillable="true" type="xs:string"/> 
</xs:sequence> 
</xs:extension> 
</xs:complexContent> 
</xs:complexType> 
</xs:schema> 

From the client I am calling this method by passing to it Subclass -- ObjectB:

ObjectB obj; getObject(obj);

In the request XML object is represented like that:

<obj xsi:type="q1:ObjectB" xmlns:q1="http://mypackage.com/xsd"&gt; 
<id>1</id> 
<name>test</name> 
<q1:phone>123</q1:phone> 
</obj> 

But on the server side no matter if I am passing instance of ObjectA or instance of ObjectB i am getting always instance of superclass ObjectA, even when xsi:type specifies that object is of subclass ObjectB type. As a result I am not getting values present on ObjectB and getting only values defined in superclass ObjectA.

Same structure worked fine in axis1 ans xsi:type was respected.

Maybe it is some configuration in axis2.

I would be really thankful for any help.