使用nusoap库从php web服务返回嵌套数组
我想以这种方式从php中的web服务返回嵌套数组使用nusoap库从php web服务返回嵌套数组,php,web-services,nusoap,Php,Web Services,Nusoap,我想以这种方式从php中的web服务返回嵌套数组 $ordArr = array("orderid"=>$orderId,"orderdate"=>$orderdate,"ordertype"=>$ordertype); $userArr = array("userid"=>$userId,"name"=>$name,"address"=>$address); 我可以用这种方式为单个数组定义复杂类型并返回单个数组 $server->wsdl->
$ordArr = array("orderid"=>$orderId,"orderdate"=>$orderdate,"ordertype"=>$ordertype);
$userArr = array("userid"=>$userId,"name"=>$name,"address"=>$address);
我可以用这种方式为单个数组定义复杂类型并返回单个数组
$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')
)
);
但是如何为嵌套数组定义complext类型,如
$userArr = array("userid"=>$userId,"name"=>$name,"address"=>$address,"order"=>$ordArr);
我对数组的复杂类型中定义的类型有点困惑
与字符串类似,将类型设置为“xsd:string”,但对于数组类型=?使用nusoap lib在php中创建web服务的addcomplextype中使用的嵌套数组
$ordArr = array("orderid"=>$orderId,"orderdate"=>$orderdate,"ordertype"=>$ordertype);
$userArr = array("userid"=>$userId,"name"=>$name,"address"=>$address);
为要添加到主数组或外部数组中的嵌套数组定义第一个复杂类型
$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'),
)
);
现在,将这个复杂类型添加到主数组中,将复杂类型添加到数组中,以定义数组类型。将复杂类型创建为struct/array时,该类型用于将该对象类型定义到数组中
现在定义的用户复杂类型
$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'),
)
);
需要更多详细信息,请参阅本教程