Hi Marc --
If I understand the first part of your question correctly, you want to
have your service method return the data in a Collection object back to
the client as a typed array.
There is an array serializer/deserializer that will work fine for this
purpose. They're in the "ser" package along with the Bean serializers
and such.
I've been interested in doing the same sort of stuff. Sending back
typed arrays is about as close to returning a Collections object as
I've been able to get. For the most part this works for my (current)
needs. It doesn't require custom serialization (unless the array
type does).
-BWD.
-----Original Message-----
From: Marc Wilson [mailto:
Sent: Tuesday, July 27, 2004 8:46 PM
To: [EMAIL PROTECTED]
Subject: Advanced serialization of Collections and Maps
Hi,
I have a few questions about serialization and deserialization of
Collections and Maps with Axis.
Basically our app has a Business Object Model of DTOs (Data Transfer
Objects) that it relatively complex from a Soap p.o.v., ie: it contains
lists, sets and maps within it. All the lists, sets and maps in the BOM
contain elements of one type only.
We are evaluating the practicallity of exposing the API of our application
(currently accessed through Stateless Session EJBs) also as a WebService
through AXIS.
I have got it working for "simple" return values, but for complex return
values as I expected it doesn't work as easily.
What I want to be able to do is use the serialization and deserialization
abilities of Axis to serialise any and all Collections in the return values
as typed arrays (I'll get to maps in a minute).
I think that the BeanSerializer can currently serialize a List as
xsd:anyType[] or soapenc:Array, but I need it to be typed when it is
serialized so that any client can generate everything it needs from the wsdl
and not have to worry about any complex mappings etc..
I plan to markup the DTOs and use xDoclet and to generate custom
serialization and deserialization classes:
ie:
----------------------------------------
class MouseDTO
{
/**
* @mymarkuptag.list type=Cat
*/
public List getCats() ...
/**
* @mymarkuptag.set type=Dog
*/
public Set getDogs() ...
}
class CatDTO
{
..
}
class DogDTO
{
..
}
----------------------------------------
would generate
----------------------------------------
class FooDTOSerialiser extends MyCollectionSerializer
{
FooDTOSerialiser()
{
super(new String[]{"cats","dogs"}, new Class[]{CatDTO.class,
DogDTO.class});
}
}
----------------------------------------
Then I plan to write a MyCollectionSerializer base class which will act like
the current BeanSerializer (probably will extend it) but for the properties
that were specified in the constructor (ie: cats) it will do the
serialisation as if it were an array of that type (ie: CatDTO[]).
Maps would work the same way except that there would be two classes marked
up for the key and value types and they would be serialised as an array of a
type that contains the key and value types (ie: TypeATypeBPair[], where
TypeATypeBPair is { TypeA key, TypeB value}).
Now, the questions:
Does what I want to do make sense?
Is there anything out in Axis land that does this already?
Does anyone have any ideas/input into how I would/should write the base
serializer classes?
Any other ideas of feedback would be appreciated
Cheers
-Marc
_________________________________________________________________
SEEK: Now with over 50,000 dream jobs! Click here:
http://ninemsn.seek.com.au?hotmail