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
|
- RE: Declaring Arrays in Doc/Lit Wrapped Style Wei Hsu
- RE: Declaring Arrays in Doc/Lit Wrapped Style Anne Thomas Manes
- RE: Declaring Arrays in Doc/Lit Wrapped Style Anne Thomas Manes