I have c# web service and I can successfully retrieve the data using nusoap lib. However I have no idea what's the best way to display or retrieve the value from the result using PHP. I prefer foreach But I wanted a cleaner look and a common way to display it. The last time I used PHP was 6 years ago and never consumed web service. here's my code:
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'];
}
here's the result
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. I did not create the web service. thank you so much