protected function retrieveWSDL($wsdl) { $parts = parse_url($wsdl); if (!isset($parts['scheme'], $parts['host'])) { return $wsdl; } //use the md5 of the baseURL as the folder $baseURL = $this->buildURL($parts); $cacheFolder = CACHE_DIR . '/WSDL/' . md5($baseURL); //save the filename as is $cacheFile = basename($this->buildURL($parts, true)); if (!($wsdl_cache = ini_get('soap.wsdl_cache_ttl'))) { $wsdl_cache = 86400; // one day } $cache = new DiskCache($cacheFolder, $wsdl_cache, true); $cache->preserveFormat(); //make sure we save the raw data if ($cache->isFresh($cacheFile)) { $wsdl_data = $cache->read($cacheFile); } else { $ch = curl_init($wsdl); foreach ($this->initArgs as $key => $value) { if (preg_match("/CURLOPT_/", $key)) { curl_setopt($ch, constant($key), $value); } } if ($this->authUser) { curl_setopt($ch, CURLOPT_HTTPAUTH, constant('CURLAUTH_' . strtoupper($this->authType))); curl_setopt($ch, CURLOPT_USERPWD, $this->authUser . ':' . $this->authPassword); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); if (!($wsdl_data = curl_exec($ch))) { if (!($error = curl_error($ch))) { $error = "Unable to retrieve WSDL {$wsdl}"; } Kurogo::log(LOG_WARNING, "Unable to retrieve WSDL {$wsdl}: {$error}", 'soap'); throw new KurogoException($error); } //save the WSDL to cache $cache->write($wsdl_data, $cacheFile); curl_close($ch); } /* retrieve the imports */ $parsedWSDL = $this->parseWSDL($wsdl_data); foreach ($parsedWSDL->getImports() as $import) { $url = $baseURL . $import; $this->retrieveWSDL($url); } // use the local cached WSDL file $wsdl = $cache->getFullPath($cacheFile); return $wsdl; }