PEAR::SOAP, WSDL_Cache patch

From: Date: Wed, 13 Nov 2002 01:08:21 +0000
Subject: PEAR::SOAP, WSDL_Cache patch
Groups: php.pear.dev php.soap 
Request: Send a blank email to pear-dev+get-10746@lists.php.net to get a copy of this message
Was testing the latest PEAR::SOAP (unreleased 0.7.1 from CVS) and found that now w/ the use of the utility classes HTTP_Request and Net_URL in the WSDL_Cache class, it gives errors when trying to read a local WSDL file. What used to work in 0.6.x before: $client = new SOAP_Client('GoogleSearch.wsdl', true); no longer works w/ 0.7.1, giving errors in the two utility classes mentioned above, same problem when using a "file://" location. I just made a kludge to avoid that (see below). BTW, there is also a problem w/ the client generated from the WSDL (I think). I will send another email later on that respect. Here is the kludge: --- WSDL.php-orig Tue Nov 12 16:32:28 2002 +++ WSDL.php Tue Nov 12 16:38:01 2002 @@ -618,20 +618,32 @@ } } if (!$md5_wsdl) { - $uri = explode('?',$wsdl_fname); - $rq = new HTTP_Request($uri[0], $proxy_params); - // the user agent HTTP_Request uses fouls things up - if (isset($uri[1])) { - $rq->addRawQueryString($uri[1]); - } - $result = $rq->sendRequest(); - if (PEAR::isError($result)) { - return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname, ".$rq->getResponseCode(), $wsdl_fname); - } - $file_data = $rq->getResponseBody(); - if (!$file_data) { - return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname, no http body", $wsdl_fname); - } + // is it a local file? + if (!preg_match('/^(http|file):\/\//',$wsdl_fname)) { + if (!file_exists($wsdl_fname)) { + return $this->_raiseSoapFault("Unable to read local WSDL $wsdl_fname", $wsdl_fname); + } + if (function_exists('file_get_contents')) { + $file_data = file_get_contents($wsdl_fname); + } else { + $file_data = implode('',file($wsdl_fname)); + } + } else { + $uri = explode('?',$wsdl_fname); + $rq = new HTTP_Request($uri[0], $proxy_params); + // the user agent HTTP_Request uses fouls things up + if (isset($uri[1])) { + $rq->addRawQueryString($uri[1]); + } + $result = $rq->sendRequest(); + if (PEAR::isError($result)) { + return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname, ".$rq->getResponseCode(), $wsdl_fname); + } + $file_data = $rq->getResponseBody(); + if (!$file_data) { + return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname, no http body", $wsdl_fname); + } + } $md5_wsdl = md5($file_data); @@ -1335,4 +1347,4 @@ } } -?> \ No newline at end of file +?> ===== --- Jesus M. Castagnetto (jcastagnetto@yahoo.com) Research: http://metallo.scripps.edu/ Personal: http://www.castagnetto.org/ __________________________________________________ Do you Yahoo!? U2 on LAUNCH - Exclusive greatest hits videos http://launch.yahoo.com/u2

« previous php.pear.dev (#10746) next »