我有c#web服务,我可以使用nusoap lib成功检索数据。但是我不知道使用PHP从结果中显示或检索值的最佳方法是什么。 我更喜欢foreach但我想要一个更清洁的外观和一种常见的方式来展示它。我最后一次使用PHP是在6年前,从未使用过Web服务。这是我的代码:
require_once('lib/nusoap.php');
$client = new nusoap_client('https://www.source.com/webservice.asmx?WSDL',true);
$params = array('paramkey' => 'blahblahblah');
$result = $client->call('operationname', $params);
print_r($result); //for testing output
print_r($result['Node']['SubNode']['Table'][0]); //for testing getting the 1st array value
foreach ($result['Node']['SubNode']['Table'] as $key ) {
echo $key['DISPLAY_NAME'].'<br/>';
echo $key['ID'];
}
这是结果
Array ( [OperationResult] => Array ( [NewDataSet] => Array
( [Table] => Array ( [0] => Array ( [EMPLOYER_ID] => 4675 [DISPLAY_NAME] =>
1st Jilin University [STREET1] => 17 Xinmin Street ????71
[CITY_NM] => Jilin [COUNTRY_NM] => China [PHONE_NUM] => 0431-88782222 ) [1] => Array
( [EMPLOYER_ID] => 4399 [DISPLAY_NAME] => 1st Tashkent Medical Institute [WEBSITE] =>
http://tashmedun.blogspot.com/ ) [2] => Array ( [EMPLOYER_ID] => 4350 [DISPLAY_NAME] =>
Aarhus University Hospital [STREET1] => Dept. of Surgery [STREET2]
=> PO Box 365 [CITY_NM] => Aalborg [ZIP] => 9100 [COUNTRY_NM] => Denmark )))))
FYI。我没有创建Web服务。 非常感谢你