Compound Types
SOAP arrays have a very specific set of rules, which require that you specify both the element type and array size. SOAP also supports multidimensional arrays, but not all SOAP implementations support multidimensional functionality. (Check your chosen SOAP toolkit for details.)
To create an array, you must specify it as an
xsi:type
of Array
. The array
must also include an arrayType
attribute. This
attribute is required to specify the data type for the contained
elements and the dimension(s) of the array. For example, the
following attribute specifies an array of 10 double values:
arrayType="xsd:double[10]"
. In contrast, the
following attribute specifies a two-dimensional array of strings:
arrayType="xsd:string[5,5]"
.
Here is a sample SOAP response with an array of double values:
<?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2001/09/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <ns1:getPriceListResponse xmlns:ns1="urn:examples:pricelistservice" SOAP-ENV:encodingStyle="http://www.w3.org/2001/09/soap-encoding"><return
xmlns:ns2="http://www.w3.org/2001/09/soap-encoding"
xsi:type="ns2:Array" ns2:arrayType="xsd:double[2]">
<item xsi:type="xsd:double">54.99</item>
<item xsi:type="xsd:double">19.99</item>
</return>
</ns1:getPriceListResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Note that the arrayType
is set to
xsd:double[2]
. Each element ...
Get Web Services Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.