On Thu, Nov 11, 2010 at 5:30 PM, Vladimir Duloglo <[email protected]> wrote:
> I am experiencing some problems converting XML requests on the server side, > in case XML requests contain xsi:type parameter. > > > > The setup is following > > > > Two objects: > > > > ObjectSubClass extends ObjectSuperClass > > > > A webservice with a method: getObject(ObjectSuperClass obj) > > > > In wsdl these objects defined in the following way: > > > > <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" > > > targetNamespace="http://mypackage.com/xsd"> > > <xs:complexType name="ObjectSuperClass"> > > <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="ObjectSubClass"> > > <xs:complexContent> > > <xs:extension base="ax21:ObjectSuperClass"> > > <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 – > ObjectSubClass which has one extrafield -- phone: > > > > ObjectSubClass obj = new ObjectSubclass(); > > obj.setId(“some id”); > > obj.setName(“some name”); > > obj.setPhone(“some phone”); > > getObject(obj); > > > > In the request XML object is represented like that: > > > > <obj xsi:type="q1:ObjectSubClass" xmlns:q1="http://mypackage.com/xsd"> > > <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 > ObjectSuperClass or instance of ObjectSubClass I am getting always instance > of superclass ObjectSuperClass, even when xsi:type specifies that object is > of subclass ObjectSubClasstype. As a result I am not getting values present > on ObjectSubClass and getting only values defined in superclass > ObjectSuperClass. > hi, may be i'm wrong, i'm still a newbe here. :) but, didn't the casting of the superclass object to the subclass object work? thanks, > > > 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. > > > > > -- Supun Malinga, Software Engineer, WSO2 Inc. http://wso2.com http://wso2.org email - [email protected] <[email protected]> mobile - 071 56 91 321
