cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sbery...@progress.com>
Subject RE: serializing subclass of base class gets base class name in output
Date Sat, 19 Dec 2009 20:05:29 GMT
Hi

You may want to try @XmlElements listing Bar.class and Gork.class
instead of @XmlElement(name = "foo"), let us know please if it helps

Cheers, Sergey.

-----Original Message-----
From: KARR, DAVID (ATTCINW) [mailto:dk068x@att.com] 
Sent: 19 December 2009 19:50
To: users@cxf.apache.org
Subject: serializing subclass of base class gets base class name in
output

I had originally had a "Foo" class in my REST server which was
serializing fine as "<foo>".  I then realized that this was really a
base class, so I added the subclasses of it, which are "Bar" and "Gork".
The declaration of the list of these is the following:

    @XmlElementWrapper(name = "childFoos")
    @XmlElement(name = "foo")
    private List<Foo>   childFoos;

When I serialize this, I get exactly what I specified here, such that
each "Foo" element is a "foo".

What I want is to have a "<childFoos>" list, but each element will
either be "<bar>" or "<gork>", depending on the subclass.  The data I
have in each "foo" is correct, reflecting whether it was a "bar" or a
"gork", but I want the wrapper to change based on that.

I tried to remove the "XmlElement" wrapper here, but that just resulted
in "<childFoos>" wrapping a list of "<childFoos>", not a mixture of
"<bar>" or "<gork>" elements.

Mime
View raw message