Java Reference
In-Depth Information
Dealing with Arrays
Problem
You need to define an array data type in a schema that your service will use, but the BP disal-
lows using arrays.
Solution
Define a complex type, and give its maxOccurs attribute a value of greater than 0. If you want
to replicate a true Java array, give the attribute an actual value to bound the number of cells it
holds. If you want to replicate a Java list, specify unbounded .
Discussion
Section 4.3.3 of the BP 1.1 disallows using SOAP-encoded array types because of the
number of interoperability problems that arrays present. You are not allowed to use the soa-
penc:Array type or the wsdl:arrayType .
You use the array encoding type like this:
...
<xsd:restriction base="soapenc:Array">
<xsd:sequence>
<xsd:element name="x" type="xsd:string"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute ref="soapenc:arrayType"
wsdl:arrayType="tns:MyArrayType[]"/>
...
This type would serialize in a SOAP message as something like the following code:
<MyArray soapenc:arrayType="tns:MyArrayType[]">
<x>123</x>
<x>456</x>
</MyArray>
Luckily, it's easy to address this problem. All you have to do to overcome this issue is avoid
use of the array type altogether, and define a complex type whose maxOccurs attribute value
is unbounded , as shown in the following:
Search WWH ::




Custom Search