简体   繁体   English

使用nusoap lib从php web服务返回嵌套数组

[英]nest array return from php web service using nusoap lib

I want to return nested array from web service in php upto i have do like this way 我想从PHP的Web服务返回嵌套数组,直到我这样做

$ordArr = array("orderid"=>$orderId,"orderdate"=>$orderdate,"ordertype"=>$ordertype);

$userArr = array("userid"=>$userId,"name"=>$name,"address"=>$address);

i am able to define complex type for single array and return single array using this way 我能够为单个数组定义复杂类型并使用这种方式返回单个数组

$server->wsdl->addComplexType(
 'User',
 'complexType',
 'struct',
 'all',
 '',
      array(
       'userId' => array('name' => 'userId',
           'type' => 'xsd:int'),
       'name' => array('name' => 'name',
           'type' => 'xsd:string'),
       'address' => array('name' => 'address',
           'type' => 'xsd:string')
      )
);

but how to define complext type for the nested array like 但是如何为嵌套数组定义复杂类型

$userArr = array("userid"=>$userId,"name"=>$name,"address"=>$address,"order"=>$ordArr);

i little bit confused into the type define in complex type for array 我有点困惑类型定义为数组的复杂类型

like for string set type as 'xsd:string' but for the array type=? 例如,对于字符串集类型为“ xsd:string”,但对于数组type =?

for the nested array used into the addcomplextype using nusoap lib to create the web service in php. 使用nusoap lib在addcomplextype中使用嵌套数组,以在php中创建Web服务。

$ordArr = array("orderid"=>$orderId,"orderdate"=>$orderdate,"ordertype"=>$ordertype);

$userArr = array("userid"=>$userId,"name"=>$name,"address"=>$address);

define first complex type for nested array which you want to add into the main array or outer array. 为要添加到主数组或外部数组中的嵌套数组定义第一个复杂类型。

$server->wsdl->addComplexType(
 'Order',
 'complexType',
 'struct',
 'all',
 '',
      array(
       'orderid' => array('name' => 'orderid',
           'type' => 'xsd:int'),
       'orderdate' => array('name' => 'orderdate',
           'type' => 'xsd:string'),
       'ordertype' => array('name' => 'ordertype',
           'type' => 'xsd:string'),
      )
);

now add this complex type into the main array complex type into the array to define the array type. 现在将此复杂类型添加到主数组中,将复杂类型添加到数组中以定义数组类型。 When you create the complex type as struct/array that type was used to define that object type into the array 当您将复杂类型创建为struct / array时,该类型用于将对象类型定义到数组中

now define the user complex type for 现在定义用户复杂类型

$userArr = array("userid"=>$userId,"name"=>$name,"address"=>$address,"order"=>$ordArr);

$server->wsdl->addComplexType(
 'User',
 'complexType',
 'struct',
 'all',
 '',
      array(
       'userId' => array('name' => 'userId',
           'type' => 'xsd:int'),
       'name' => array('name' => 'name',
           'type' => 'xsd:string'),
       'address' => array('name' => 'address',
           'type' => 'xsd:string'),
       'order' => array('name' => 'order',
           'type' => 'tns:Order'),
      )
);

need more details see this tutorial 需要更多详细信息,请参阅本教程

tutorial for nested array 嵌套数组教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM