【发布时间】:2012-03-20 05:57:28
【问题描述】:
当我访问从 nusoap 返回的数据数组时,我遇到了重复的标签。我尝试使用复杂类型,但它没有按照我要求的方式工作,即包含在特定标签而不是项目标签中。我通过以下方式声明一个复杂类型。
$server->wsdl->addComplexType(
'ProductArray',
'complexType',
'struct',
'all',
'',
array(
'pid' => array('name' => 'pid', 'type' => 'xsd:string'),
'pname' => array('name' => 'pname', 'type' => 'xsd:string')
)
);
我注册了我的函数:
$server->register('ProdInfo', // method name
array('product' => 'tns:product'), // input parameters
array('return' => 'tns:ProductArray'), // output parameters
'urn:productcomplextype', // namespace
'urn:productcomplextype/ProdInfo', // soapaction
'rpc', // style
'encoded', // use
'Product Information' // documentation
);
功能
function ProdInfo ($product) {
//code
return array('pid'=>$pid,'pname'=>$pname);
}
如果我对单个返回值进行硬编码,我将获得价值。但作为一个数组,我在显示正确值时遇到了问题。它抛出以下输出
Array
(
[pid] => Array
[pname] => Array
)
请帮忙
更新
这是由于与从数组中的函数返回数据相关的问题。正确返回后现已解决。现在数据如下所示
Array
(
[ProductInfo] => Array
(
[0] => Array
(
[pid] => 1
[pname] => Steering
)
[1] => Array
(
[pid] => 18
[pname] => Wheel Base
)
)
)
这使得在 iPhone 应用程序中难以解析它。在 iPhone 响应中没有数据。
【问题讨论】:
-
该问题已通过简单地更改 web 服务以返回一个数组来解决。避免使用复杂类型。
标签: iphone nusoap complextype