Re: Array Confusion

Hi Brenda,

> Method 2:
>
>       <xs:complexType name="DoubleArray">
>         <xs:complexContent>
>           <xs:restriction base="soapenc:Array">
>             <xs:sequence/>
>             <xs:attribute ref="soapenc:arrayType" n1:arrayType="xs:double[]"
> xmlns:n1="http://schemas.xmlsoap.org/wsdl/"/>
>           </xs:restriction>
>         </xs:complexContent>
>       </xs:complexType>
>     </xs:schema>
[snip]
> However, method 2 has me baffled... given the following element declaration:
>
>   <xs:element name="TestDoubles">
>     <xs:complexType>
>     <xs:sequence>
>       <xs:element name="Data" type="tns:DoubleArray"></xs:element>
>     </xs:sequence>
>     </xs:complexType>
>   </xs:element>
>
> I haven't been able to come up with a valid document. The Data
> element isn't allowed to have text, but the sequence on DoubleArray
> is empty and doesn't allow child elements. What am I missing?

Well, the DoubleArray type is definitely missing a content model. It
should look more like:

<xs:complexType name="DoubleArray">
  <xs:complexContent mixed="false">
    <xs:restriction base="soapenc:Array">
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="Double"
                   type="xs:double"/>
      </xs:sequence>
      <xs:attribute ref="soapenc:arrayType" n1:arrayType="xs:double[]"
                    xmlns:n1="http://schemas.xmlsoap.org/wsdl/"/>
    </xs:restriction>
  </xs:complexContent>
</xs:complexType>

such that your Data element can be:

<Data xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      soapenc:arrayType="xs:double[]">
  <Double>1.2</Double>
  <Double>3.4</Double>
</Data>

(I'm by no means a WSDL expert, but I think that the StringArray type
should also have the soapenc:arrayType attribute specified on it.)

Briefly glancing through the WSDL/SOAP encoding specs, I think that
the authors of those specs might be missing the fact that when you
derive a type by restriction you must specify a content model for the
type, or specify that it's mixed, otherwise elements of that type
can't legally contain anything.

But *you* don't seem to be missing anything -- your description of
what the DoubleArray type definition is doing is absolutely correct.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Wednesday, 17 July 2002 13:37:48 UTC