Your original array definition is correct,
and it conforms to the WS-I recommendation. The only significant difference in
your definition versus the WS-I recommendation is that your array supports a
null value in addition to no occurrences. There’s also the minor
difference in that you did not name your array type, but you don’t need
to do that unless you need to reference the type separately from the element
(e.g., if you were using rpc/literal, or if you have
multiple elements that have the same type). To design your array just like the
recommendation, you should define it like this: <element name="test" type=”testType/> <complexType name=”testType”> <sequence> <element minOccurs="0" maxOccurs="unbounded"
name="value" type="xsd:string"
/> </sequence> </complexType> If you want to support a null value, then
define it like this: <element name="test" type=”testType/> <complexType name=”testType”> <sequence> <element minOccurs="0" maxOccurs="unbounded"
name="value" type="xsd:string"
nillable=”true”/> </sequence> </complexType> Your interpretation of the WS-I
recommendation is inaccurate – as you say – it results in an extra
level of nesting that you don’t want. You can stick with what you have unless
you have a requirement to reference the array type separate from the element. Then
use the WS-I approach. - Anne From: Wei Hsu
[mailto:[EMAIL PROTECTED] Hi all, I have a question about the XML declaration for an array in
doc/lit wrapped style. For a server side method with the following
signature: String test(String[] value) I had been representing it with the following element: <element name="test"> <complexType> <sequence> <element
minOccurs="0" maxOccurs="unbounded" name="value"
type="xsd:string" nillable="true"/> </sequence> </complexType> </element> This allows me to correctly generate a proxy that matches my
original method when I use WSDL2Java. However, I recently checked out the
WS-I Basic Profile 1.0, and it gave the following example as the correct way to
represent soapenc:Array. <!-start à <xsd:element name="MyArray1"
type="tns:MyArray1Type"/> <xsd:complexType name="MyArray1Type"> <xsd:sequence> <xsd:element name="x"
type="xsd:string" minOccurs="0"
maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <!-end à That would mean that for the same "test" method, I
should actually be declaring the "test" element as the following: <element name="test"> <complexType> <sequence> <element
name="arr" type="tns:MyStringArray"/> </sequence> </complexType> </element> <complexType name="MyStringArray"> <sequence> <element minOccurs="0"
maxOccurs="unbounded" name="value"
type="xsd:string" nillable="true"/> </sequence> </complexType> However, when I try to use WSDL2Java on that, I end up with
the following signature: String test(MyStringArray arr) Where MyStringArray contains a String[] inside. This
makes sense, but it sort of confuses me as to which direction is the
"correct" one. Is there any harm using my current way of
representing an array? I also found the following article, which sort of validates
my approach. <exerpt> As part of section 5.2.3 of the WS-I
basic profile, there is an example showing of the right way to encode an array.
Basically, you just use standard XSD "minOccurs" and
"maxOccurs" on an element declaration to represent an array. If you,
in addition, want to define a specific reuseable type for that array, you
create a complex type containing a sequence containing the repeating element. </exerpt> Any thoughts? -Wei |
- Declaring Arrays in Doc/Lit Wrapped Style Wei Hsu
- RE: Declaring Arrays in Doc/Lit Wrapped Style Anne Thomas Manes
- Anne Thomas Manes