1

我在 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 的响应类似的响应吗?

4

0 回答 0