2 回答
TA贡献1735条经验 获得超5个赞
您从 Web 服务收到的响应具有json encoded负载。要使用该有效载荷,您首先需要json_decode它。
以下是如何循环遍历结果项以访问列表中的每个单独项。
$itemList = json_decode($webServiceResponse->getPropsListResult);
foreach ($itemList as $item) {
// access props like this
echo $item->id;
echo $item->Material;
echo $item->SalesDescription;
// and so on...
}
尝试使用这样的代码:
$soapclient = new SoapClient('http://****.com/Pages/WebService/Keramat/KeramatWebService.asmx?wsdl');
try {
$response = $soapclient->getCanboPropsList();
$itemList = json_decode($response->getPropsListResult);
foreach ($itemList as $item) {
// access props like this
echo $item->id;
echo $item->Material;
echo $item->SalesDescription;
// and so on...
}
}
catch(Exception $e) {
echo ($soapclient->__getLastResponse());
echo PHP_EOL;
echo ($soapclient->__getLastRequest());
}
TA贡献1998条经验 获得超6个赞
您也许可以执行以下操作:
$result = <webservice response>;
foreach ($result->getPropsListResult as $prop) {
$prop['SalesPrice']; // To get salesprice
$prop['PlantName']; // To get plant name
}
- 2 回答
- 0 关注
- 196 浏览
添加回答
举报
