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