You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Rodrigo Ruiz <rr...@gridsystems.com> on 2003/05/21 15:11:58 UTC

Interface Array Serialization Problem

Hi all,

I am having problems serializing arrays of interfaces with AXIS 1.0.

My system have to deal with two client versions, one older than the other. I
cannot suppose the clients will be upgraded, as my company does not offer
free upgrades of the client product. Because of this, I had to split my
internal data classes into two versions. I have done the following:

public interface Data_1_0 {
  ...
}

public interface Data_2_0 extends Data_1_0 {
  ...
}

public class Data implements Data_1_0, Data_2_0 {
  ...
}

public class MyService {
  private Data data[];

  public Data_1_0[] getData() {
    return data;
  }

  public Data_2_0[] getData2() {
    return data;
  }
}

I must keep both getDataX methods in order to correctly send data to older
clients.

The Data_2_0 interface has some more getters than the 1.0 version, so they
are not compatible (a client expecting a 1.0 instance will complain on
receiving unknown fields)

The problem is that AXIS is always sending the array as being of type
Data_2_0[], indepently of which method I invoke.

I have been surfing the source code, and I have found that the
ArraySerializer uses the Class.getComponentType() method to find out which
type the array is. Could this be a bug? I think the serializer should use
the OperationDescription information, where the correct return type should
appear, instead of determining it through reflection.

As a workaround, I create a correctly typed array, and copy my internal
array into it, but I would prefer to avoid an array copy, as I consider it
should be unnecessary.

I am just wondering if this behaviour can be considered a bug, or not :-)

Thanks in advance,

--
GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
Parc Bit - Son Espanyol        Research Dpt.
07120 Palma de Mallorca        rruiz@gridsystems.com
Baleares - EspaƱa              Tel:+34-971435085
www.gridsystems.com            Fax:+34-971435082