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 Chris Williamson <ch...@wolfram.com> on 2003/09/26 22:25:30 UTC

array question

Hey I have a question about arrays.

In the ws-i spec it states that arrays should be defined such as...

<complexType name="StringArray">
  <xsd:sequence>
    <xsd:element name="str" type="xsd:string" minOccurs="0"
maxOccurs="unbounded"/>
  </xsd:sequence>
</complexType>

And this turns out...

<StringArray>
  <str>blah</str>
  <str>moreblah</str>
</StringArray>

Should arrays be defined in a complexType all to themselves?  Or I noticed
that Axis supports something like this...

<complexType name="CompoundObject">
  <xsd:sequence>
    <xsd:element name="str" type="xsd:string" minOccurs="0"
maxOccurs="unbounded"/>
    <xsd:element name="x" type="xsd:int"/>
  </xsd:sequence>
</complexType>

Which translates to something like...

<CompoundObject>
  <str>blah</str>
  <str>moreblah</str>
  <x>3</x>
</CompoundObject>

In Axis it translates to methods such as...

  String[] a = compoundObject.getStr();
  Integer b = compoundObject.getX();

Is it proper to declare an array as a separate object such as the first
definition?  And then use it in a Compound object.  Or is it ok to define an
array directly in the CompoundObject like in the second definition?

Thanks,

Chris