summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlibrary/SSRS/Report.php10
-rwxr-xr-xlibrary/SSRS/Soap/NTLM.php26
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);