通过基于PHP WSDL的Web服务返回一个数组数组

时间:2009-04-14 15:54:24

标签: arrays web-services wsdl

我正在努力解决以下问题:

我有一个基于PHP的Web服务,需要被各种消费者使用 客户端。只要我保持简单,一切正常。我认为Axis2和.NET不喜欢soapenc:array中的WSDL定义,所以我为映射对象数组创建了列表类型:

<xsd:complexType name="CourseList">
  <xsd:sequence>
    <xsd:element name="Courses" type="tns:Course" minOccurs="0" maxOccurs="unbounded"/>
  </xsd:sequence>
</xsd:complexType>

现在,如果我包含类似CourseLists的列表(使用相同的WSDL过程),则.NET会因Axis2(ADB)处理此数据而失败。 我检查了使用soapUI通过线路传输的XML;看起来很合理。

我真的很喜欢这个。任何提示都将受到高度赞赏。

TIA

 KB22

1 个答案:

答案 0 :(得分:2)

这个问题比犯罪还要老,但是从来没有得到过回答,当我最近遇到同样的问题时,我一直在努力寻找答案。可能有更好的方法来做到这一点,但我最终最终做的就是这样。

这实际上甚至是一个更高级别的三维阵列,但一般原则是相同的。

<xs:element name="myOtherArray">
<xs:complexType>
    <xs:sequence>
        <xs:element name="someInsideArrayProperty" type="xs:int"/>
    </xs:sequence>
</xs:complexType>

<xs:element name="myArray">
<xs:complexType>
    <xs:sequence>
        <xs:element name="someArrayProperty" type="xs:string"/>
        <xs:element name="yetAnotherArray" maxOccurs="unbounded" type="ns:myOtherArray"/>
    </xs:sequence>
</xs:complexType>

<xs:element name="myResponse">
<xs:complexType>
    <xs:sequence>
        <xs:element name="myResponseArray" maxOccurs="unbounded">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="someProperty" type="xs:int"/>
                    <xs:element name="someOtherProperty" type="xs:string"/>
                    ...
                    <xs:element name="anotherArray" type="ns:myArray" maxOccurs="unbounded"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:sequence>
</xs:complexType>