2 回答

TA貢獻(xiàn)1735條經(jīng)驗(yàn) 獲得超5個(gè)贊
您從 Web 服務(wù)收到的響應(yīng)具有json encoded負(fù)載。要使用該有效載荷,您首先需要json_decode它。
以下是如何循環(huán)遍歷結(jié)果項(xiàng)以訪問(wèn)列表中的每個(gè)單獨(dú)項(xiàng)。
$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貢獻(xiàn)1998條經(jīng)驗(yàn) 獲得超6個(gè)贊
您也許可以執(zhí)行以下操作:
$result = <webservice response>;
foreach ($result->getPropsListResult as $prop) {
$prop['SalesPrice']; // To get salesprice
$prop['PlantName']; // To get plant name
}
- 2 回答
- 0 關(guān)注
- 98 瀏覽
添加回答
舉報(bào)