I don't think you have to declare the inherited fields sides and size in the derived type Square.
Check if you have a serializer declared for Square in your generated stub. public XxxxxStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { if (service == null) { super.service = new org.apache.axis.client.Service(); } else { super.service = service; } ... qName = new javax.xml.namespace.QName("...", "Square"); cachedSerQNames.add(qName); cls = xxx.Square.class; cachedSerClasses.add(cls); cachedSerFactories.add(beansf); cachedDeserFactories.add(beandf); .... } Then check with the tcpmonitor what was send back by the server. Christophe > -----Original Message----- > From: Zhou Jian Han [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 21, 2004 1:50 PM > To: [EMAIL PROTECTED] > Subject: RE: Does Axis support polymorphism (dynamic send back the derived > class) > > Thanks for the reply. > Yes, I did include all the types in .wsdl, and I also see wsdl2java > generate all the java beans, such as Shape.java; Square.java (also > Square is extended from Shape), so all the generated code look fine. > The only problem is after the request come back from server, if I send a > 'Square' object back, the BeanDeserializer still try to biuld 'Shape' > object, and does not recognize the additional field on the Square. > Any idea? does this polymorphism work if you use Axis as both client and > server soap? > > Here are the part of my wsdl: > > <complexType name="Shape"> > <sequence> > <element name="name" type="xsd:string" minOccurs="0" maxOccurs="1" > nillable="true"/> > <element name="sides" type="xsd:int" minOccurs="1" maxOccurs="1"/> > </sequence> > </complexType> > <complexType name="Square"> > <complexContent> > <extension base="ns:Shape"> > <sequence> > <element name="name" type="xsd:string" minOccurs="0" maxOccurs="1" > nillable="true"/> > <element name="sides" type="xsd:int" minOccurs="1" maxOccurs="1" > default="4"/> > <element name="size" type="xsd:int" minOccurs="1" maxOccurs="1"/> > </sequence> > </extension> > </complexContent> > </complexType> > > > <message name="getPolyRequest"> > <part name="type" type="xsd:int"/> > </message> > > <message name="polytestResponse"> > <part name="out" type="ns:Shape"/> > </message> > > <portType name="polymorphPortType"> > <operation name="getPoly"> > <documentation>Service definition of function > ns__getPoly</documentation> > <input message="tns:getPolyRequest"/> > <output message="tns:polytestResponse"/> > </operation> > </portType> > > > Thanks, > Georgia > -----Original Message----- > From: Christophe Roudet [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 21, 2004 10:35 AM > To: [EMAIL PROTECTED] > Subject: RE: Does Axis support polymorphism (dynamic send back the > derived class) > > > If you generate your client from a wsdl (with wsdl2java) make sure that > your > derived types are declared in. > > <complexType abstract="true" name="Shape"> > <sequence> > <element name="size" type="xsd:int"/> > .... > </sequence> > </complexType> > > <complexType name="Square"> > <complexContent> > <extension base="tns1:Shape"> > <sequence> > .... > </sequence> > </extension> > </complexContent> > </complexType> > > Christophe > > > -----Original Message----- > > From: Zhou Jian Han [mailto:[EMAIL PROTECTED] > > Sent: Thursday, October 21, 2004 1:02 PM > > To: [EMAIL PROTECTED] > > Subject: Does Axis support polymorphism (dynamic send back the derived > > class) > > > > Hi, > > I have a based class named Shape, and a derived class named Square( > Square > > extends Shape). > > Is that possible I declare a method in service: > > public Shape getShape(int type) throws RemoteException > > and send back the Square Object? > > > > By the way, I use gSoap(c/c++ soap) on server side, and apache Axis on > > client side, it looks like server send out the Square object, but > client > > is not recognize the derived object, it is complain about "Invalid > element > > in Shape- Square.size" (and 'size' is the field in Square, not in > Shape). > > > > Does any one have sample that polymorphism is working in Java Axis? > > > > Thanks in Advance! > > Georgia >