Title: Is this a bug in serialization?
Tom,
 
I don't see how I can fix this by changing the hashcode function (or the equals function for that matter)! I think the basic problem is with the multiRefValues map kept in SerializationContextImpl. As long as the objects put into this map don't have hashcode or equals implementations, they will be compared by reference and everything will be fine. But as soon as we put objects in this map with hashcode and equals implementations, we could get false hits if the two objects "happen" to have the same field values.
 
Please let me know what you think.
 
Thanks.
Naresh
-----Original Message-----
From: Tom Jordahl [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 02, 2002 12:05 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Is this a bug in serialization?

 
This is a feature of soap encoding. 
You only get a single copy of your object transmitted in the XML so the other side knows that the two references are the same thing.
 
It sounds like we may need to change the hashcode function emitted by WSDL2Java (or you can edit it by hand).
 
--
Tom Jordahl
Macromedia
 
-----Original Message-----
From: Naresh Bhatia [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 02, 2002 12:00 PM
To: '[EMAIL PROTECTED]'
Subject: Is this a bug in serialization?

I had sent the following message to the user list, but got no response. Perhaps it is more appropriate for the developer list because it brings up an issue with Axis serialization. I would really appreciate a response from the group.
 
Thanks.
Naresh Bhatia
 
-----Original Message-----
From: Naresh Bhatia [mailto:[EMAIL PROTECTED]]
Sent: Saturday, June 29, 2002 1:17 PM
To: '[EMAIL PROTECTED]'
Subject: Is this a bug in serialization?

I am trying to serialize two different objects, both of which happen to have the same value. Unfortunately the generated SOAP message contains only one value for the object and two references pointing to it. Is this a bug or am I missing something?

Here's how I create the two objects in Java:

    Message msg1 = new Message("Error");
    Message msg2 = new Message("Error");

When the serialization framework encounters the second object, it thinks that it is the same as the first one (because the hashcode function returns the same value) and hence creates a reference to the first object:

  <msg1 href="#id8"/>
  <msg2 href="#id8"/>

  <multiRef id="id8"
            SOAP-ENC:root="0"
            soapenv:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/
            xsi:type="ns14:Message"
            xmlns:ns14="http://test">
   <text xsi:type="xsd:string">Error</text>
  </multiRef>

I have created the Message object using WSDL2Java and it contains the equals() and hashcode() methods.

Please help!

Naresh Bhatia

Reply via email to