axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Craig <>
Subject Problem with serializing subclasses
Date Thu, 15 May 2003 13:43:05 GMT
Hi everyone,

I was trying to implement a service based on the following classes:

public class MyClass;
public class MySubclass extends MyClass;

and the server method:

public MyClass myClassService()
  return new MySubclass();

I set up serializers for MyClass and MySubclass like so:



Trouble is that the return object from myClassService is serialized as a
MyClass object (as per the method declaration) even though it's really a
MySubclass. As a result I lose the extra fields in MySubclass.

My question is first, is this intended behaviour - it seemed to me that
the BeanSerializer should serialize based on the real class of the
object rather than what is declared in the method. This would make it
far easier to work with subclasses. Is there a reason why this isn't

Secondly, given that this is the normal behaviour, can anyone suggest a
good workaround? Can I implement a custom serializer that checks the
real class and then calls the relevant BeanSerializer?



View raw message