Question regarding serializing & deserializing objects in XStream

View: New views
2 Messages — Rating Filter:   Alert me  

Question regarding serializing & deserializing objects in XStream

by gomzynewbie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I am an XStream newbie. I was trying to build a simple RESTLET service which returns an ArrayList<Person> where Person is defined as below.

class Person
{
    String name;
    int age;
}

Now while trying to convert it back to ArrayList<Person> using fromXML method it throws a com.thoughtworks.xstream.converters.ConversionException $Person

How do I pass on the class information at runtime from the service to the client(which doesnt know the format of the XML returned by the service)? Do writing custom converters solve this..how?

I tried to search for this particular problem but couldnt find one. :( Thanks in advance.

Regards,
Gautam  

Re: Question regarding serializing & deserializing objects in XStream

by Jörg Schaible-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Gautam,

gomzynewbie wrote:

>
> Hi all,
>
> I am an XStream newbie. I was trying to build a simple RESTLET service
> which returns an ArrayList<Person> where Person is defined as below.
>
> class Person
> {
>     String name;
>     int age;
> }
>
> Now while trying to convert it back to ArrayList<Person> using fromXML
> method it throws a com.thoughtworks.xstream.converters.ConversionException
> $Person
>
> How do I pass on the class information at runtime from the service to the
> client(which doesnt know the format of the XML returned by the service)?
> Do writing custom converters solve this..how?
>
> I tried to search for this particular problem but couldnt find one. :(
> Thanks in advance.

Serialization does normally not contain the class definition itself. The
class has to be on the client also to generate a new instance.

- Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email