Coder Social home page Coder Social logo

php-ssrs's Introduction

php-ssrs

PHP library for connecting to SSRS over SOAP

Requirements

Although it isn't mandatory to use Composer, without it you will need to set up autoloading or require the invidual classes manually. We highly recommend you install php-ssrs using Composer, its easy to get started: https://getcomposer.org/

Dependencies:

  • PHP5.4
  • PHP curl module (on ubuntu, its sudo apt-get install php5-curl)

Installation / Usage

The easiest way to use php-ssrs is to install it with composer. To include the library in to your project using composer, run the following command:

$ php composer.phar require chartblocks/php-ssrs:~1.0.

OR add the following to your composer.json file:

{
    "require": {
        "chartblocks/php-ssrs": "~1.0."
    }
}

See the wiki for information on how to get started!

<?php
$ssrs = new \SSRS\Report('http://server/reportserver/', array('username' => 'thomas', 'password' => 'secureme'));
$ssrs->listChildren('/Report Folder');

php-ssrs's People

Contributors

deanstalker avatar jberns88 avatar leith avatar rb-cohen avatar smokeybrandie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-ssrs's Issues

error handling on non-xml responses

First, thanks for a great library. I ran into an issue today where my SSRS server was returning a 503 http error code. When that happened, php-ssrs threw an exception "String could not be parsed as XML", but didn't include any detail such as the http response code or the raw response from the server.

Looking at the callCurl() method in NTLM.php, it looks like the code is always expecting a xml response when the http code is between 300 and 600, but in my case today, a 503 error was thrown without valid xml. Similarily, a 404 could be thrown without valid xml.

Could the error handling be updated to send the http code and raw response for cases like this?

Thanks for your help.

Class SSRS_Object_ExecutionParameters

Hi

I've managed to connect to our remote reports server - but specifying parameters is throwing the following error:

FatalErrorException in tempRoutesController.php - Class 'App\Http\Controllers\SSRS_Object_ExecutionParameters' not found"

Current code is:

`

$ssrs = new \SSRS\Report(env('SSRS_ADDRESS'), array('username' => env('SSRS_USER'), 'password' => env('SSRS_PASSWORD')));

$result = $ssrs->loadReport(env('SSRS_REPORT'));
$reportParameters = array(
    'param_1' => '1'
    ,'param_2'=> '1'
);

$parameters = new SSRS_Object_ExecutionParameters($reportParameters);

$ssrs->setSessionId($result->executionInfo->ExecutionID)->setExecutionParameters($parameters);

$output = $ssrs->render('HTML4.0'); // PDF | XML | CSV
echo $output;

`

Searching through the library - I can't see any class named SSRS_Object_ExecutionParameters, any ideas where I'm going wrong?

Regards
Ben

Toggle Item

Can you explain how I can use the toggleItem method?

I can execute it just fine:

$ssrs->printr($ssrs -> toggleItem("24iT0R0x0"));

returns:

stdClass Object
(
    [Found] => 1
)

but nothing happens.

edit:
Ok, rerendering after the toggle helps a lot. I should really post to this github everytime I have some sort of a problem because it seems to be fixed right after ;) .

CURL error: Could not resolve proxy

how to solve this error? please help me

Fatal error: Uncaught exception 'SSRS\Soap\Exception' with message 'CURL error: Could not resolve proxy: http=nebula' in C:\xamppPHP5\htdocs\php-ssrs\library\SSRS\Soap\NTLM.php:165 Stack trace: #0 C:\xamppPHP5\htdocs\php-ssrs\library\SSRS\Soap\NTLM.php(135): SSRS\Soap\NTLM->callCurl('http://172.22.0...', '<?xml version="...', 'http://schemas....') #1 [internal function]: SSRS\Soap\NTLM->__doRequest('<?xml version="...', 'http://172.22.0...', 'http://schemas....', 1, 0) #2 C:\xamppPHP5\htdocs\php-ssrs\library\SSRS\Report.php(240): SoapClient->__call('GetItemDefiniti...', Array) #3 C:\xamppPHP5\htdocs\php-ssrs\library\SSRS\Report.php(240): SSRS\Soap\NTLM->GetItemDefinition(Array) #4 C:\xamppPHP5\htdocs\php-ssrs\samples\GetItemDefinition.php(13): SSRS\Report->getItemDefinition('/Pages') #5 {main} thrown in C:\xamppPHP5\htdocs\php-ssrs\library\SSRS\Soap\NTLM.php on line 165

Cached WSDL file is the same for every request

If you set the cache_wsdl_path because you don't have access to the temp dir on your web server, the cached WSDL is used even if it does not apply to the request you are making.

Example:

$options = array(
    'username' => 'myuser',
    'password' => 'mypass',
    'cache_wsdl_path' => 'my/writeable/dir/file.cache',
);

$ssrs = new \SSRS\Report("http://myserver/ReportServer", $options);

$ssrs->listChildren('/ReportsFolder'); // Works

$ssrs->getReport('/ReportsFolder/Example Report'); // Fails with error

You'll receieve the error Function ("LoadReport") is not a valid method for this service where LoadReport is whatever the subsequent action you are attempting to take is. This is because the WSDL has been cached and it is not refreshed between actions.

The same would occur if you redefined the object but use the same cache path between different requests.

$options = array(
    'username' => 'myuser',
    'password' => 'mypass',
    'cache_wsdl_path' => 'same/file.cache',
);

$ssrs = new \SSRS\Report("http://myserver/ReportServer", $options);

$ssrs->listChildren('/ReportsFolder'); // Works

$ssrs1 = new \SSRS\Report("http://myserver/ReportServer", $options);

$ssrs1->getReport('/ReportsFolder/Example Report'); // Fails with error

I was hoping to be able to define the connection once and reuse it for all the requests I had to make, rather than redefining the SSRS\Report object every time. Is there a way to have this thing automatically download new WSDL when the action has changed?

Content-Length header must not be set

The content length hader must not be set since CURL sets the length automatically

So I suggest to remove the following line:
$headers[] = 'Content-Length: ' . strlen($data);

From function generateHeaders in File NTLM.php

ListChildren is not a valid method

I try to get all the reports using the following code:

$ssrs = new \SSRS\Report("http://10.10.2.106/reportserver", $options);
$result = $ssrs->ListChildren("/", true);

But I get the following error:

Fatal error: Uncaught SoapFault exception: [Client] Function ("ListChildren") is not a valid method for this service in D:\IIS_sites\SSRS_tester\vendor\chartblocks\php-ssrs\library\SSRS\Report.php:207 Stack trace: #0 D:\IIS_sites\SSRS_tester\vendor\chartblocks\php-ssrs\library\SSRS\Report.php(207): SoapClient->__call('ListChildren', Array) #1 D:\IIS_sites\SSRS_tester\vendor\chartblocks\php-ssrs\library\SSRS\Report.php(207): SSRS\Soap\NTLM->ListChildren(Array) #2 D:\IIS_sites\SSRS_tester\index.php(18): SSRS\Report->listChildren('/', true) #3 {main} thrown in D:\IIS_sites\SSRS_tester\vendor\chartblocks\php-ssrs\library\SSRS\Report.php on line 207

What's causing this problem?

undefined function

Hi,

I get the following error when trying to use your library

PHP Fatal error: Call to undefined function SSRS\Soap\curl_init() in /var/www/vhosts/ccd/include/vendor/chartblocks/php-ssrs/library/SSRS/Soap/NTLM.php on line 124

What am I doing wrong?

Regards

SOS ! String could not be parsed as XML

in vendor\chartblocks\php-ssrs\library\SSRS\Soap\ServerException.php (line 12)

public $faultcode;    
public $faultstring;    
public $faultactor;    
  static function fromResponse($string) {        
            $xml = new \SimpleXMLElement($string);        
            $ns = $xml->getNamespaces(true);        
            $soap = $xml->children($ns['soap']);        
            $body = $soap->Body->children($ns['soap']);        
                if (isset($body->Fault)) {

Please help Thanks !!!

Zend Server Config Assistance

Could you help me to understand how I would install this package into a Zend Server environment?

I am running Zend Server 6.1.0 on Windows Server 2008 R2.
My SSRS is on another server which is running SQL Server 2008 R2 SSRS under Windows Server 2008 R2.

The PHP guts appear to live in the following folder:
C:\Program Files (x86)\Zend\ZendServer\bin

Any assistance you could give me in "autoloading" this package would be appreciated, as I am not using composer to do the install.

Joe

Html - rendering images

I m having issues rendering a report to html as the report contains charts which are rendered as images on the SSRS server. The browser into which the report is rendered does not have authorization to access the charts (images) in the report so they fail to load resulting in a page of blank squares !

Is there a way around this problem ? Any session or cookie settings which will pass the authenticated session back to the browse ?

Thank you.

Pagination?

first thanks for this, it's fantastic and saved me a TON of time!!

Just a quick question about pages... some of our reports have 50 pages or more. Is there any good way to separate them out? Even if it's just on the front end, I just don't want to make people have to scroll through 50 pages with a mouse wheel haha.

Thanks again!

Fatal error: Class 'SSRS\Soap\NTLM' not found

Hello, I'm trying to use your library, but I cant get it work, how I have to set the Name Spaces?

PHP Version 5.4
WebServer: Centos 6.4
MSSQL Server 2008 R2

require('library/SSRS/Report.php');
$ssrs = new \SSRS\Report(SERVICE_URL,$options);
$ssrs->listChildren('/Report Folder');

I got: Fatal error: Class 'SSRS\Soap\NTLM' not found in ...

I'm using Basic Authentication

How Am I setup the library to load all the required classes.

sorry for post it here, but I don't now how to contact you in regard with this topic, and thanks for any help you could give me

Pass DataSource Credentials?

I need to keep my SSRS datasource as "prompt for credentials" since we are also using another solution that requires that, but I'm unsure how to set the DataSourceCredentials in my solution. I get the error: System.Web.Services.Protocols.SoapException: One or more data source credentials required to run the report have not been specified.

Here's my code:

        $options = [
            'username' => $this->getParameter('ssrs_user'),
            'password' => $this->getParameter('ssrs_password')
        ];

        $ssrs = new SSRS\Report($this->getParameter('ssrs_server'), $options);
        $result = $ssrs->loadReport($this->getParameter('ssrs_base').'/'.$request->get('report'));

        $ssrs->setSessionId($result->executionInfo->ExecutionID);
        $parameters = json_decode($request->get('parameters'),true);
        $ssrs->setExecutionParameters(new SSRS\Object\ExecutionParameters($parameters));

        $output = $ssrs->render('HTML4.0'); // PDF | XML | CSV | HTML4.0 | Excel
        return $output;

What else do I need to add?

Soap Fault -Could not connect to host

Hi I am getting Could not connect to host error. I've checked my tmp folder and wsdl cache data is available. Please help

Error<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>

Notice: Undefined property: SoapFault::$detail in E:\CMS\bin\SSRSReport.php on line 687
SSRSReportException Object
(
[errorCode] =>
[errorDescription] => Could not connect to host
[soapFault] => SoapFault Object
(
[message:protected] => Could not connect to host
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => E:\DMS\bin\SSRSReport.php
[line:protected] => 347
[trace:Exception:private] => Array
(
[0] => Array
(
[function] => __doRequest
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] =>
/Sales/Price List

                                [1] => http://TAV:80/ReportServer/ReportExecution2005.asmx
                                [2] => http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/LoadReport2
                                [3] => 1
                                [4] => 0
                            )

                    )

                [1] => Array

Toolbar not showing

Hi,

I am trying to use the library to render some reports and I have some Issues:

  • The Toolbar is not rendered even with the following code:

$output = $ssrs->render('HTML4.0', array('Toolbar' => true));

I also noticed that long reports are note paged, resulting in a huge scroll throughout the report.

How can I solve this issues?

Thank you!

Check if folder is writebale is on parent instead of the folder itself

NTLM.php Method "setCachePath"

If cache folder has been set to "d:/tmp" (using sys_get_temp_dir() method, for example)
this line:
$folder = dirname($path);
will return "d:/" and check if this folder is writeable.

That means that the writeable check will be made on the parent folder instead of the cache folder itself.

_cacheExpiry not set

When using NTLM, I noticed that the WSDL file was being re-cached on every request.

Looking in SSRS\Soap\NTLM.php, I see that _cacheExpiry defaults to null, and the function setCacheExpiry() is never called.

Should this function be called in the constructor or elsewhere?

Thanks for your help.

Include images from ssrs report to html page

Any way to include images from ssrs reports into the page html? When rendering ssrs report content as .pdf or Excel file, the report images are included in the file output. When rendering report content as html, only "marker" where the image should be displayed.

I am unable to create connection with SSRS server - Fatal error: Class 'SSRS\Soap\NTLM' not found

Getting Error : Fatal error: Class 'SSRS\Soap\NTLM' not found

I am using following code :

    require(__DIR__ . '../../../vendor/autoload.php');
    //require('SSRS/library/SSRS/SSRSReport.php');
    require('chartblocks/php-ssrs/library/SSRS/Report.php');

    try {
        $options = array(
            'username' => 'chetu\krishnagsasa',
            'password' => 'Feb@2019asd'
        );

        $ssrs = new \SSRS\Report('http://192.168.10.1/ReportServer_SQLDEV', $options);
         //   $results = $ssrs->listRenderingExtensions();
        $result = $ssrs->loadReport('Report Project3/Report3');
        
        $ssrs->setSessionId($result->executionInfo->ExecutionID);
        $ssrs->setExecutionParameters(new SSRS_Object_ExecutionParameters($result->executionInfo->Parameters));

        $output = $ssrs->render('PDF'); // PDF | XML | CSV
        $output->download('report.pdf');
    } catch (\SSRS\SSRSReportException $ex) {
        die($ex->getMessage());
    }

SSRS_SOAP_EXCEPTION not found

The class SSRS_SOAP_EXCEPTION is not in the zip but is referenced in the NTML.php file on line 145
My error:

Fatal error: Class 'SSRS\Soap\SSRS_Soap_Exception' not found in *snip* on line 143

I have changed this from:

throw new SSRS_Soap_Exception('CURL error: ' . curl_error($handle), curl_errno($handle));

to:

throw new Exception('CURL error: ' . curl_error($handle), curl_errno($handle));

Which works, so maybe it's something you should look into.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.