Re: Serialization/deserialization of custom types

From: Phil Goodwin <Phil.Goodwin_at_Sun.COM>
Date: Fri, 30 Aug 2002 14:38:33 -0700

This is not an easy thing to do. The first step is to write the
serializer/deserializer class (that's the really hard part), then you
write a SerializerFactory and a DeserializerFactory for it and register
those using config.xml. One email is simply not nearly enough room to
describe how to write a custom serializer. If you want to learn how
you've made a good start by looking at the Appendix in the
specification. You should also download the source code and poke around
in the com.sun.xml.rpc.encoding package and its sub-packages. You'll
almost certainly want to extend SOAPObjectSerializerBase and write your
own Builder class. Generating code for a serializer that is similar to
the one you need can also be very helpful. You should be able to copy
the (De)SerializerFactory code almost verbatim. You'll likely be able to
simplify your life by getting rid of the opcode processing in the
generated Serializer class. After that you'll have to look at the things
about your class that prevent it from being a Value Type. A close
reading of that appendix should give you a way to solve each of these
problems. If you run across a specific issue that you can't get past
then send an email to this list.

Naninha wrote:

>I am trying to figure out how to serialize/deserialize custom Java objects. I was hoping to be able to provide a SerializerFactory/DeserializerFactory for my custom Java objects rather than make them be JavaBean property. Can this be done?
>>From everything I have read in wsdp tutorial and JAX-RPC Specification it seems that this should be doable. In Chapter 19, Appendix: Serialization Framework, of JAX-RPC Reference Implementation, they are even talking about how would one go about doing this, and they mention com.sun.xml.rpc.encoding.soap.SOAPSerializer class, but I cannot find this class in wsdp package.
>Can anyone let me know if this is doable? And if yes what would be the steps to do this?
>I do know how to do this making my custom classes value types, but this does not fit exactly with what I am trying to do.
>I would appreciate your help.
>Thank you.

Phil Goodwin, Java Software, Sun Microsystems, 408.276.7090, or x17090
For a bowl of water give a goodly meal;
For a kindly greeting bow thou down with zeal;
For a simple penny pay thou back with gold;
If thy life be rescued, life do not withhold.
Thus the words and actions of the wise regard;
Every little service tenfold they reward.
But the truly noble know all men as one,
And return with gladness good for evil done.