Hi John,

Yes, it is perfectly possible to handle arrays of beans with references to other beans, and similar structures. For some examples of code that does this, download the Axis samples from my comparison of SOAP performance at http://www.sosnoski.com/presents/cleansoap/comparing.html This also has a sample of using Castor for the same thing with Axis.

As for Nathan's framework, this sort of thing can certainly be done but it's a lot of work and not very good from a performance standpoint. JDK 1.4 and later comes with XMLEncoder and XMLDecoder that do basically this type of XML serialization (though with XMLEncoder/XMLDecoder the format is fixed and not very interoperable with non-Java applications).

 - Dennis

--
Dennis M. Sosnoski
Enterprise Java, XML, and Web Services
Training and Consulting
http://www.sosnoski.com
Redmond, WA  425.885.7197


John Menke wrote:

Thanks Nathan, so basically Axis can't do it.  That's why nobody has
responded.  The docs seem to indicate it can be done...so much for the docs.
I don't have the resources to code a framework at the moment.  There was an
article i saw on using Castor and Axis maybe i can do that.

-jm

-----Original Message-----
From: Nathan Wardle [mailto:[EMAIL PROTECTED]
Sent: Sunday, November 14, 2004 7:31 PM
To: [EMAIL PROTECTED]
Subject: RE: does anyone have complex serialization working?


We've actually ended up writing our own serialiser and deserialiser based on a reflection excerpt from Better, Faster, Lighter Java by Bruce Tate and Justin Gehtland (pg 70 something). We combined this with the strategy pattern (one class per type of strategy (ie ArrayStrategy, Map, Collection, Bean, Primitive etc) with an isApplicable method which takes a class or class name and a process method wich does the (de)serialisation for that type of object). We added the ability to handle beans with references to another bean by passing around a context map containing all objects that had been (or were being) processed. We also added a type conversion function to each strategy because we are passing message between .Net client and java server. We then just passed the xml messages.

It's a bit of work, but works well.

Code is unavailable, sorry, but the resulting xml looks something like this:

<item class=\"interop.array\" componentType=\"interop.object\" id=\"0\">
        <item class=\"interop.string-object\">My array</item>
        <item class=\"interop.array\" itemClass=\"interop.string-object\" 
id=\"1\">
                <item class=\"interop.string-object\">1</item>
                <item class=\"interop.string-object\">2</item>
        </item>
        <item class=\"ObjectWithReferences\" id=\"2\">
                <referenceObject class=\"ObjectWithReferences\" refid=\"2\"/>
        </item>
</item>

for this object:

Object[] arrayObject = new Object[]{"My array", new String[]{"1", "2"},
                                new ObjectWithReferences()};

ObjectWithReferences test class:

class ObjectWithReferences
{

        private ObjectWithReferences referenceObject = this;

        public ObjectWithReferences()
        {

        }

        /**
         * @param object
         * @return
         *
         * @see java.lang.Object#equals(java.lang.Object)
         */
        public boolean equals(Object object)
        {
                if (!(object instanceof ObjectWithReferences)) return false;
                ObjectWithReferences them = (ObjectWithReferences) object;

                return (them.getReferenceObject() == them) && (referenceObject 
== this);
        }

        /**
         * @return
         *
         * @see java.lang.Object#hashCode()
         */
        public int hashCode()
        {
                return super.hashCode();
        }

        /**
         * @return Returns the object1.
         */
        public ObjectWithReferences getReferenceObject()
        {
                return referenceObject;
        }

        /**
         * @param object1
         *                   The object1 to set.
         */
        public void setReferenceObject(ObjectWithReferences referenceObject)
        {
                this.referenceObject = referenceObject;
        }
}


-----Original Message----- From: John Menke [mailto:[EMAIL PROTECTED] Sent: Monday, 15 November 2004 11:06 AM To: Axis Subject: does anyone have complex serialization working?


Is it even possible to serialize an array of beans where the beans have references to another bean? Nobody has been able to come up with a working example. beanMapping is not working for me. I have posted several times and nothing... i'm beginning to think it's not possible.

-jm

Reply via email to