diff options
author | arron.woods <arron.woods@deae1e92-32f9-c189-e222-5b9b5081a27a> | 2011-05-19 11:50:12 +0000 |
---|---|---|
committer | arron.woods <arron.woods@deae1e92-32f9-c189-e222-5b9b5081a27a> | 2011-05-19 11:50:12 +0000 |
commit | 3c48293ff2a103591d1c2d97fba56cf7ff39d0dc (patch) | |
tree | f7976d2d7d1f4aeeb2ffeb5b6394785e0d6745e2 /library/SSRS | |
parent | e2df384496c7a833869178be7cc088c8768a6320 (diff) | |
download | php-ssrs-0.1.3.zip php-ssrs-0.1.3.tar.gz php-ssrs-0.1.3.tar.bz2 |
Tagged 0.1.30.1.3
Diffstat (limited to 'library/SSRS')
-rwxr-xr-x | library/SSRS/Report.php | 10 | ||||
-rwxr-xr-x | library/SSRS/Soap/NTLM.php | 26 |
2 files changed, 24 insertions, 12 deletions
diff --git a/library/SSRS/Report.php b/library/SSRS/Report.php index 52c7396..e6220da 100755 --- a/library/SSRS/Report.php +++ b/library/SSRS/Report.php @@ -47,7 +47,7 @@ class SSRS_Report { * @param array $options */ public function __construct($baseUri, $options = array()) { - $this->_baseUri = rtrim($baseUri, '/'); + $this->setBaseUri($baseUri); if (array_key_exists('username', $options)) { $this->setUsername($options['username']); @@ -58,6 +58,14 @@ class SSRS_Report { } } + public function setBaseUri($uri) { + $this->_baseUri = rtrim($uri, '/'); + } + + public function getBaseUri() { + return $this->_baseUri; + } + /** * Sets the Soap client class with the Execution Uri so that the connection to the web service can be made. * Should be the custom SOAP NTLM class to bypass NTLM security. diff --git a/library/SSRS/Soap/NTLM.php b/library/SSRS/Soap/NTLM.php index 339f688..9132eae 100755 --- a/library/SSRS/Soap/NTLM.php +++ b/library/SSRS/Soap/NTLM.php @@ -93,7 +93,7 @@ class SSRS_Soap_NTLM extends SoapClient { public function cacheWSDL($fileContents) { $result = file_put_contents($this->_cachePath, $fileContents); if ($result) { - $this->setCacheWSDLPermission(0666 ); + $this->setCacheWSDLPermission(0666); } } @@ -107,18 +107,18 @@ class SSRS_Soap_NTLM extends SoapClient { public function fetchWSDL() { if ($this->isCacheValid() === false) { - $wsdlContent = $this->_callCurl($this->_uri); + $wsdlContent = $this->callCurl($this->_uri); $this->cacheWSDL($wsdlContent); } } public function __doRequest($data, $url, $action) { $this->_lastRequest = (string) $data; - $this->_lastResponse = $this->_callCurl($url, $data, $action); + $this->_lastResponse = $this->callCurl($url, $data, $action); return $this->_lastResponse; } - protected function _callCurl($url, $data = null, $action = null) { + public function callCurl($url, $data = null, $action = null) { $handle = curl_init(); curl_setopt($handle, CURLOPT_URL, $url); curl_setopt($handle, CURLOPT_FAILONERROR, false); @@ -130,26 +130,30 @@ class SSRS_Soap_NTLM extends SoapClient { curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_NTLM); $headers = array( - 'Method: POST', + 'Method: ' . ($data === null) ? 'GET' : 'POST', 'Connection: Keep-Alive', 'User-Agent: PHP-SOAP-CURL', - 'Content-Type: text/xml; charset=utf-8', - 'Content-Length: ' . strlen($data), - 'SOAPAction: "' . $action . '"', ); - curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); if ($data !== null) { + $headers[] = 'Content-Type: text/xml; charset=utf-8'; + $headers[] = 'Content-Length: ' . strlen($data); curl_setopt($handle, CURLOPT_POSTFIELDS, $data); } + if($action !== null){ + $headers[] = 'SOAPAction: "' . $action . '"'; + } + + curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); + $response = curl_exec($handle); - if($response === false) { + if ($response === false) { throw new SSRS_Soap_Exception('CURL error: ' . curl_error($handle), curl_errno($handle)); } $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); - if ($httpCode !== 200){ + if ($httpCode !== 200) { throw new SSRS_Soap_Exception('HTTP error: ' . $httpCode . ' ' . $response, $httpCode); } curl_close($handle); |