Title: 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