Hi Naresh,

I tend to prefer the first approach.  And the Java APIs can make it
fairly easy:

Eg:

public List getBooks () {
        return books;
}
public Book[] getBookArray () {
        return (Book[])gooks.toArray(new Book[0]);
}

I'd also add that many of these will get much easier once Java adds
support for real Generics.


On Tue, 2003-02-18 at 11:11, Naresh Bhatia wrote:
> Hi,
> 
> I am trying to find the best practices around serializing /
> deserializing Lists and Maps. So far I have come up with the following
> approaches. Please feel free to give me your comments as well as list
> other approaches that you may have found useful. My overall assumption
> is that it is heck of a lot easier to work with Lists and Maps inside
> a Java application rather than arrays, which is the preferred way for
> SOAP!
> 
> 1) Maintain separate internal data structures for Java and external
> data structures for SOAP. Translate between the two as needed. For
> example:
> 
>     public Book {
>         private String isdn; // key
>         ...
>     }
> 
>     public BookStoreInternal {
>         private HashMap books;  // key is isdn, value is Book
>         ...
>     }
> 
>     public BookStoreSoap {
>         private Book[] books;
>         ...
>     }
> 
>     Advantages: Interoperable with other SOAP toolkits
>     Disadvantages: Ugly to maintain two sets of data structures and
> conversion routines
> 
> 2) Keep just one set of data structures, use Lists and Maps as needed.
> Write custom serializers and deserializers to translates the lists and
> maps to SOAP arrays and vice versa.
> 
>     Advantages: Interoperable with other SOAP toolkits
>     Disadvantages: Ugly to maintain custom serializers and
> deserializers
> 
> 3) Use the Axis framework to serialize / deserialize Lists and Maps
> 
>     Advantages: No maintenance
>     Disadvantages: Not interoperable with other toolkits (I know Maps
> don't work with .NET)
> 
> What would be ideal is if I can use Lists and Maps as I feel like and
> Axis would automatically translate them to / from SOAP arrays. I don't
> mind giving hints to Axis about object types / keys - but this
> approach would be far more easier to implement and maintain that any
> of the three mentioned above. Comments?
> 
> Thanks.
> Naresh
-- 
=======================================
Jess Sightler
Senior Developer
Exim Technologies
131 Falls Street
Greenville SC 29601
Phone: 864-679-4651
=======================================



Reply via email to