Variable Length Arrays
SOAPam Server allows arrays be declared as variable length. When an array is declared as variable length the size of the structure containing the array varies according to the number of elements in the array. Variable length arrays need not be the last element in a structure. Structure elements that follow a variable length array will be relocated in the IPM buffer according to the size of the array.
An array is marked as variable length by applying the variableArray attribute to the array element. Variable length arrays must also be marked with the dependsOn attribute which indicates which structure element indicates the actual size of the array. The element indicated by the dependsOn attribute must occur before the array itself.
The following sample structure contains a variable length array.
<type name="myIpm">
<element name="stringCount" type="int" />
<element name="theStrings" type="string" size="20" minOccurs="0" maxOccurs="20" variableArray="1" dependsOn="stringCount" />
<element name="endOfStructure" type="int" />
</type>
In this example, the length of the theStrings array and the location, or offset, of the endOfStructure field will vary according to the value of stringCount. For example:
Value of stringCount | number of theStrings elements | offset of endOfStructure | total structure size |
---|---|---|---|
1 | 1 | 24 | 28 |
10 | 10 | 204 | 208 |
30 | 30 | 604 | 608 |
Note that when an array is marked as variable length, the actual number of array elements may exceed the specified value of maxOccurs. This is so that structures may be declared in DDL that conform to DDL structure size limits, but may actually exceed DDL size limits.