Zend_Soap返回数组

时间:2012-02-24 21:10:58

标签: php web-services zend-framework nusoap zend-soap

我在Nusoap上构建了一个Soap服务器。其中一种方法返回如下:

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://test.webservice/soap/">
   <SOAP-ENV:Body>
      <ns1:get_itemsResponse xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
         <return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:SelectItem[18]">
            <item xsi:type="tns:SelectItem">
               <id xsi:type="xsd:int">6</id>
               <name xsi:type="xsd:string">This is the first item</name>
            </item>
            <item xsi:type="tns:SelectItem">
               <id xsi:type="xsd:int">7</id>
               <name xsi:type="xsd:string">This is another item</name>
            </item>
...

现在我已经切换到Zend Soap,我只是无法使响应看起来像上面那样。我得到的最接近的是这样的:

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://another.webservice/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <SOAP-ENV:Body>
      <ns1:get_ItemsResponse>
         <return xsi:type="ns1:SelectResponse">
            <items SOAP-ENC:arrayType="ns1:SelectItem[18]" xsi:type="ns1:ArrayOfSelectItem">
               <item xsi:type="ns1:SelectItem">
                  <id xsi:type="xsd:int">6</id>
                  <name xsi:type="xsd:string">This is the first item</name>
               </item>
               <item xsi:type="ns1:SelectItem">
                  <id xsi:type="xsd:int">7</id>
                  <name xsi:type="xsd:string">This is another item</name>
               </item>
...

我使用Zend_Soap的自动发现功能,这些是涉及的两个部分:

class SelectResponse
{
    /** @var SelectItem[] */
    public $items;
}

class SelectItem
{
    /** @var int */
    public $id;

    /** @var string */
    public $name;

}

您是否知道如何使用Zend_Soap获得与Nusoap相似的响应?

0 个答案:

没有答案