Journal
Thursday April 17, 2003
Modified nusoap.php
I spent hours trying to consume the GlobalWeather web service using PHPObject's three-step method to no avail. I could get results from all the operations except the most important - getWeatherReport(). It was irritating and totally illogical. I couldn't see why it worked for AirportWeather and not this. I analysed the wsdl, searched forums, etc. couldn't find the answer.
When I used PHP to try to connect to the web service directly, I also couldn't get the appropriate response. So I decided it is not PHPObject specific and finally took on the daunting task of deciphering the nusoap.php class.
After much 'tracing' (to borrow Flash's term), I narrowed down to the getOperations method of the wsdl class in nusoap.php.
Dietrich had indicated in that method:
* NOTE: currently only supports multiple services of differing binding types
* This method needs some work
I didn't understand initially. Then analysing the wsdl of GlobalWeather again, I realized that the operation getWeatherReport() is binded to a different service of the same bing type (SOAP)! What had happened is that nusoap picked up the list of operations on both services, but always overwrote the array containing the operations with the last service queried, so getWeatherReport() is missing from the list of available operations.
I modified the getOperations method of the wsdl class to support multiple services of the same binding type (SOAP). Now we can consume the wonderful GlobalWeather web service :)
{
if ($bindingType == 'soap') {
$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
}
$tmp = array();
// loop thru ports
foreach($this->ports as $port => $portData) {
// binding type of port matches parameter
if ($portData['bindingType'] == $bindingType) {
// get binding
foreach($this->bindings[ $portData['binding'] ]['operations'] as $key => $val)
$tmp[$key] = $val;
// return $this->bindings[ $portData['binding'] ]['operations'];
}
}
return $tmp;
// return array();
}
|
Comments
Post a comment
|
