cvs: pear /Services_Weather/Weather Ejse.php Globalweather.php
| From: | Alexander Wirtz | Date: | Tue, 08 Nov 2005 12:13:59 +0000 |
| Subject: | cvs: pear /Services_Weather/Weather Ejse.php Globalweather.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-36152@lists.php.net to get a copy of this message | ||
eru Tue Nov 8 07:13:59 2005 EDT
Modified files:
/pear/Services_Weather/Weather Ejse.php Globalweather.php
Log:
o Changed retrieval of SOAP data to avoid delays on cached items
http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Ejse.php?r1=1.17&r2=1.18&ty=u Index: pear/Services_Weather/Weather/Ejse.php diff -u pear/Services_Weather/Weather/Ejse.php:1.17 pear/Services_Weather/Weather/Ejse.php:1.18 --- pear/Services_Weather/Weather/Ejse.php:1.17 Thu Oct 13 06:09:45 2005 +++ pear/Services_Weather/Weather/Ejse.php Tue Nov 8 07:13:57 2005 @@ -16,7 +16,7 @@ // | Authors: Alexander Wirtz <alex@pc4p.net> | // +----------------------------------------------------------------------+ // -// $Id: Ejse.php,v 1.17 2005/10/13 10:09:45 eru Exp $ +// $Id: Ejse.php,v 1.18 2005/11/08 12:13:57 eru Exp $ /** * @package Services_Weather @@ -75,7 +75,6 @@ * @param array $options * @param mixed $error * @throws PEAR_Error - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA * @see Science_Weather::Science_Weather * @access private */ @@ -85,23 +84,33 @@ $this->Services_Weather_Common($options, $perror); if (Services_Weather::isError($perror)) { $error = $perror; - return; } + } + // }}} + // {{{ _connectServer() + /** + * Connects to the SOAP server and retrieves the WSDL data + * + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @access private + */ + function _connectServer() + { include_once "SOAP/Client.php"; $this->_wsdl = new SOAP_WSDL("http://www.ejse.com/WeatherService/Service.asmx?WSDL", array("timeout" => $this->_httpTimeout)); if (isset($this->_wsdl->fault) && Services_Weather::isError($this->_wsdl->fault)) { - $error = Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__); - return; + return Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__); } eval($this->_wsdl->generateAllProxies()); if (!class_exists("WebService_Service_ServiceSoap")) { - $error = Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__); - return; + return Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__); } - $this->_weatherSoap = &new WebService_Service_ServiceSoap; + + return true; } // }}} @@ -184,6 +193,14 @@ $this->_weather = $weather; $locationReturn["cache"] = "HIT"; } else { + // Check, if the weatherSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_weatherSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + $weather = $this->_weatherSoap->getWeatherInfo($id); if (Services_Weather::isError($weather)) { @@ -232,6 +249,14 @@ $this->_weather = $weather; $weatherReturn["cache"] = "HIT"; } else { + // Check, if the weatherSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_weatherSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + // ...as last function $weather = $this->_weatherSoap->getWeatherInfo($id); @@ -353,6 +378,14 @@ $this->_forecast = $forecast; $forecastReturn["cache"] = "HIT"; } else { + // Check, if the weatherSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_weatherSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + // ...as last function $forecast = $this->_weatherSoap->GetNineDayForecastInfo($id); http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Globalweather.php?r1=1.28&r2=1.29&ty=u Index: pear/Services_Weather/Weather/Globalweather.php diff -u pear/Services_Weather/Weather/Globalweather.php:1.28 pear/Services_Weather/Weather/Globalweather.php:1.29 --- pear/Services_Weather/Weather/Globalweather.php:1.28 Thu Oct 13 06:09:45 2005 +++ pear/Services_Weather/Weather/Globalweather.php Tue Nov 8 07:13:57 2005 @@ -16,7 +16,7 @@ // | Authors: Alexander Wirtz <alex@pc4p.net> | // +----------------------------------------------------------------------+ // -// $Id: Globalweather.php,v 1.28 2005/10/13 10:09:45 eru Exp $ +// $Id: Globalweather.php,v 1.29 2005/11/08 12:13:57 eru Exp $ /** * @package Services_Weather @@ -73,7 +73,7 @@ /** * SOAP object to access weather data, provided by CapeScience * - * @var object $_weaterSoap + * @var object $_weatherSoap * @access private */ var $_weatherSoap; @@ -98,9 +98,20 @@ $this->Services_Weather_Common($options, $perror); if (Services_Weather::isError($perror)) { $error = $perror; - return; } + } + // }}} + // {{{ _connectServer() + /** + * Connects to the SOAP server and retrieves the WSDL data + * + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @access private + */ + function _connectServer() + { include_once "SOAP/Client.php"; $this->_wsdl = new SOAP_WSDL("http://live.capescience.com/wsdl/GlobalWeather.wsdl", array("timeout" => $this->_httpTimeout)); if (isset($this->_wsdl->fault) && Services_Weather::isError($this->_wsdl->fault)) { @@ -116,6 +127,8 @@ $this->_stationSoap = &new WebService_GlobalWeather_StationInfo; $this->_weatherSoap = &new WebService_GlobalWeather_GlobalWeather; + + return true; } // }}} @@ -156,6 +169,14 @@ */ function searchLocation($location, $useFirst = false) { + // Check, if the stationSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_stationSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + // Get search data from server and unserialize $search = $this->_stationSoap->searchByName($location); @@ -202,6 +223,14 @@ return $countries; } + // Check, if the stationSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_stationSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + // Now for the real search $countryLocs = $this->_stationSoap->searchByCountry($country); // Check result for validity @@ -246,6 +275,14 @@ $this->_location = $location; $locationReturn["cache"] = "HIT"; } else { + // Check, if the stationSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_stationSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + $location = $this->_stationSoap->getStation($id); if (Services_Weather::isError($location)) { @@ -315,6 +352,14 @@ $this->_weather = $weather; $weatherReturn["cache"] = "HIT"; } else { + // Check, if the weatherSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_weatherSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + // ...as last function $weather = $this->_weatherSoap->getWeatherReport($id);
http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Ejse.php?r1=1.17&r2=1.18&ty=u Index: pear/Services_Weather/Weather/Ejse.php diff -u pear/Services_Weather/Weather/Ejse.php:1.17 pear/Services_Weather/Weather/Ejse.php:1.18 --- pear/Services_Weather/Weather/Ejse.php:1.17 Thu Oct 13 06:09:45 2005 +++ pear/Services_Weather/Weather/Ejse.php Tue Nov 8 07:13:57 2005 @@ -16,7 +16,7 @@ // | Authors: Alexander Wirtz <alex@pc4p.net> | // +----------------------------------------------------------------------+ // -// $Id: Ejse.php,v 1.17 2005/10/13 10:09:45 eru Exp $ +// $Id: Ejse.php,v 1.18 2005/11/08 12:13:57 eru Exp $ /** * @package Services_Weather @@ -75,7 +75,6 @@ * @param array $options * @param mixed $error * @throws PEAR_Error - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA * @see Science_Weather::Science_Weather * @access private */ @@ -85,23 +84,33 @@ $this->Services_Weather_Common($options, $perror); if (Services_Weather::isError($perror)) { $error = $perror; - return; } + } + // }}} + // {{{ _connectServer() + /** + * Connects to the SOAP server and retrieves the WSDL data + * + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @access private + */ + function _connectServer() + { include_once "SOAP/Client.php"; $this->_wsdl = new SOAP_WSDL("http://www.ejse.com/WeatherService/Service.asmx?WSDL", array("timeout" => $this->_httpTimeout)); if (isset($this->_wsdl->fault) && Services_Weather::isError($this->_wsdl->fault)) { - $error = Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__); - return; + return Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__); } eval($this->_wsdl->generateAllProxies()); if (!class_exists("WebService_Service_ServiceSoap")) { - $error = Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__); - return; + return Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__); } - $this->_weatherSoap = &new WebService_Service_ServiceSoap; + + return true; } // }}} @@ -184,6 +193,14 @@ $this->_weather = $weather; $locationReturn["cache"] = "HIT"; } else { + // Check, if the weatherSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_weatherSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + $weather = $this->_weatherSoap->getWeatherInfo($id); if (Services_Weather::isError($weather)) { @@ -232,6 +249,14 @@ $this->_weather = $weather; $weatherReturn["cache"] = "HIT"; } else { + // Check, if the weatherSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_weatherSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + // ...as last function $weather = $this->_weatherSoap->getWeatherInfo($id); @@ -353,6 +378,14 @@ $this->_forecast = $forecast; $forecastReturn["cache"] = "HIT"; } else { + // Check, if the weatherSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_weatherSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + // ...as last function $forecast = $this->_weatherSoap->GetNineDayForecastInfo($id); http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Globalweather.php?r1=1.28&r2=1.29&ty=u Index: pear/Services_Weather/Weather/Globalweather.php diff -u pear/Services_Weather/Weather/Globalweather.php:1.28 pear/Services_Weather/Weather/Globalweather.php:1.29 --- pear/Services_Weather/Weather/Globalweather.php:1.28 Thu Oct 13 06:09:45 2005 +++ pear/Services_Weather/Weather/Globalweather.php Tue Nov 8 07:13:57 2005 @@ -16,7 +16,7 @@ // | Authors: Alexander Wirtz <alex@pc4p.net> | // +----------------------------------------------------------------------+ // -// $Id: Globalweather.php,v 1.28 2005/10/13 10:09:45 eru Exp $ +// $Id: Globalweather.php,v 1.29 2005/11/08 12:13:57 eru Exp $ /** * @package Services_Weather @@ -73,7 +73,7 @@ /** * SOAP object to access weather data, provided by CapeScience * - * @var object $_weaterSoap + * @var object $_weatherSoap * @access private */ var $_weatherSoap; @@ -98,9 +98,20 @@ $this->Services_Weather_Common($options, $perror); if (Services_Weather::isError($perror)) { $error = $perror; - return; } + } + // }}} + // {{{ _connectServer() + /** + * Connects to the SOAP server and retrieves the WSDL data + * + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @access private + */ + function _connectServer() + { include_once "SOAP/Client.php"; $this->_wsdl = new SOAP_WSDL("http://live.capescience.com/wsdl/GlobalWeather.wsdl", array("timeout" => $this->_httpTimeout)); if (isset($this->_wsdl->fault) && Services_Weather::isError($this->_wsdl->fault)) { @@ -116,6 +127,8 @@ $this->_stationSoap = &new WebService_GlobalWeather_StationInfo; $this->_weatherSoap = &new WebService_GlobalWeather_GlobalWeather; + + return true; } // }}} @@ -156,6 +169,14 @@ */ function searchLocation($location, $useFirst = false) { + // Check, if the stationSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_stationSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + // Get search data from server and unserialize $search = $this->_stationSoap->searchByName($location); @@ -202,6 +223,14 @@ return $countries; } + // Check, if the stationSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_stationSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + // Now for the real search $countryLocs = $this->_stationSoap->searchByCountry($country); // Check result for validity @@ -246,6 +275,14 @@ $this->_location = $location; $locationReturn["cache"] = "HIT"; } else { + // Check, if the stationSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_stationSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + $location = $this->_stationSoap->getStation($id); if (Services_Weather::isError($location)) { @@ -315,6 +352,14 @@ $this->_weather = $weather; $weatherReturn["cache"] = "HIT"; } else { + // Check, if the weatherSoap-Object is present. If not, connect to the Server and retrieve the WDSL data + if (!$this->_weatherSoap) { + $status = $this->_connectServer(); + if (Services_Weather::isError($status)) { + return $status; + } + } + // ...as last function $weather = $this->_weatherSoap->getWeatherReport($id);