Failed to connect to Reporting Service

Jun 25, 2010 at 8:51 PM
Edited Jun 28, 2010 at 12:05 PM
I tried the code sample from the project home page:
<?php
// include the SSRS library
require_once 'SSRSReport.php';

define("REPORT", "/Reports/AdventureWorks/sales orders");
//$settings = parse_ini_file("app.config", 1);
// Create a connection to the SSRS Server
$rs = NULL;
try
{
$rs = new SSRSReport(new Credentials("<server name>\<user>", "<pwd>"),"http://10.0.0.4/Reportserver");
}
catch(Exception $E)
{echo $E->GetErrorMessage(); }
...
?>
And am getting the following exception:
Failed to connect to Reporting Service 
Make sure that the url (http://10.0.0.4/Reportserver/) and credentials are correct!
I can navigate to http://10.0.0.4/Reportserver in a browser fine. I have the user set up as db_datareader and db_datawriter in both the ReportServer database and the database that contains the data that we'll be using for reporting. The authentication of my reportserver.config file is as follows:
	<Authentication>
		<AuthenticationTypes>
			<RSWindowsNTLM/>
			<RSWindowsBasic/>
		</AuthenticationTypes>
		<EnableAuthPersistence>true</EnableAuthPersistence>
	</Authentication>
The user is set up as an account on the local machine. Is there anything else that I am missing to get the authentication working properly? We're using SSRS 2008 standard edition.
Coordinator
Jun 26, 2010 at 12:12 AM

Hi Bhnat,

I assume you are using the correct username/password when you create the Credentials object. You enabled Windows Basic authentication so the connection should work. Is there a proxy in your network? if so you need to use the SSRSReport method where you can specify the proxy object.

Have you tried to use the TestSSRSConnection.php tool. You can specify the username/password, url for the SSRS server and report and the tool tests the connection to make sure the php app can connect. If the connection fails you should get better error message on why it is failing.

Hope this helps

Claudio

 

Jun 28, 2010 at 12:55 PM
Edited Jun 28, 2010 at 12:56 PM
There's no proxy server being used. I get the same error message using the TestSSRSConnection.php tool from the command line.
Failed to connect to Reporting Service                                                                       
 Make sure that the url (http://10.0.0.4/ReportServer/) and credentials are correct!                                                
                                                                                                                                    
Usage:TestSSRSConnection.php /server:<report server uri> /report:<path of report> /uid:<user name> /pwd:<password> [/datasource:<nam
e of datasource> /uid:<user name> /pwd:<password>] 
A few other things that seem odd here. Just testing to try to isolate where the issue is, I can connect to the report server web service by putting together a quick C# test program and using the ReportExecutionService object. It also seems like I can connect in php by calling the SoapClient object directly (I don't get an error in the snippet below).
require_once 'library\ssrsreport\Factory\SSRSTypeFactory.php';

$client = new SoapClient("http://10.0.0.4/ReportServer/ReportExecution2005.asmx",
                         array('login' => "<uid>",
                               'password' => "<pwd>")); 

$reportPath = "/Reports/Dev/ATCLE/Payment_Batch_Summary_singleParam";
$format = "HTML4.0";
$historyID = NULL;

$encoding = NULL;
$mimeType = NULL;
$extension = NULL;

$parameters = array(
                    'Report' => $reportPath,
                    'HistoryID' => $historyID
                   );

$stdObject = $client->LoadReport2($parameters);
Looking through the log files in C:\Program Files\Microsoft SQL Server\MSRS10.SQLSERVER08\Reporting Services\LogFiles, when I use the code where I create a new SoapClient object directly, I see the username passed in the ReportServerService_HTTP log file. But when I use the SSRSReport object, I'm not seeing the username being passed.
#Server Name: RAELEN-SVR-2008
#Software: Microsoft SQL Server Reporting Services Version 2007.0100.2531.00 ((Katmai_PCU_Main).090329-1045 )
#Version: 1.0
#Date: 06/28/2010-12:02:33
#Fields: date time cs-username s-ip s-port s-host cs-method cs-uri-stem cs-uri-query sc-status cs-bytes time-taken cs-version cs(User-Agent) cs(Cookie) sc(Cookie) cs(Referrer) 
06/28/2010 12:02:33 RAELEN-SVR-2008\phpuser 10.0.0.4 20480 lucidus.raelen.com GET /ReportServer/ReportExecution2005.asmx  200 128 21500 1.0 lucidus.raelen.com - - - 
06/28/2010 12:02:39 RAELEN-SVR-2008\phpuser 10.0.0.4 20480 RAELEN-SVR-2008 POST /ReportServer/ReportExecution2005.asmx  200 1085 3032 1.1 RAELEN-SVR-2008 - - - 
06/28/2010 12:06:01 - 10.0.0.4 20480 lucidus.raelen.com GET /ReportServer/ReportExecution2005.asmx  401 182 0 1.0 lucidus.raelen.com - - - 
06/28/2010 12:36:24 - 10.0.0.4 20480 lucidus.raelen.com GET /ReportServer/ReportExecution2005.asmx ?wsdl 401 86 0 1.0 lucidus.raelen.com - - - 
06/28/2010 12:41:34 - 10.0.0.4 20480 10.0.0.4 GET /ReportServer/ReportExecution2005.asmx ?wsdl 401 76 0 1.0 10.0.0.4 - - - 
06/28/2010 12:42:29 - 10.0.0.4 20480 lucidus.raelen.com GET /ReportServer/ReportExecution2005.asmx ?wsdl 401 187 0 1.0 lucidus.raelen.com - - - 
06/28/2010 12:47:24 RAELEN-SVR-2008\phpuser 10.0.0.4 20480 10.0.0.4 GET /ReportServer/ReportExecution2005.asmx  200 118 16 1.0 10.0.0.4 - - - 
06/28/2010 12:47:25 RAELEN-SVR-2008\phpuser 10.0.0.4 20480 RAELEN-SVR-2008 POST /ReportServer/ReportExecution2005.asmx  200 1085 188 1.1 RAELEN-SVR-2008 - - - 
Coordinator
Jun 29, 2010 at 2:44 AM

Thanks for the additional information. Not sure what is going on.

I'll try to repro the problem on my machine.

Claudio

 

 

Coordinator
Jun 30, 2010 at 2:51 PM
I was able to repro the problem on one of my machines. I'll post an update as soon as I have any news. Thanks Claudio
Coordinator
Jul 2, 2010 at 4:32 PM

I haven't found any real cause for this problem yet.

The only way I was able to repro the problem is by using the 'wrong' user account. Basically there are two users involved: one that is used by SSRS to connect to the DataSource used in the report (for instance SQL Server) and another that is used to connect to the SSRS server (you can setup user accounts using the Site Settings link on the Report page if you connect as admininstrator). As expected if you use the SQL Server account the connection fails.

Can you share the details of your installation?

Are you running the PHP code from a Windows machine?, are you using local accounts or domain accounts?

Anything specific in the SSRS configuration?, you already said Windows Basic Auth is enabled, that should be the only critical setting for the SDK to work but I might be missing something else.

Thanks

Claudio

 

 

Jul 2, 2010 at 6:24 PM
Edited Jul 2, 2010 at 6:26 PM
Thanks for looking into this.

We are running the php code from a windows machine. It is the same machine that runs the SSRS server. The account that I'm passing in the credentials is a local account.

The weird thing is that when I use php's SoapClient object directly with the same credentials, it works fine. I've been able to get a report to display within a php page using the report server web services directly (with the only problem being that even after downloading the images using the RenderStream method and passing images/ in the StreamRoot element of the DeviceInfo, the IMG elements with a src like images/11d3f3fc-0e57-4373-b43e-02adc3a86c52 still aren't displaying).

It's running on a Windows Small Business Server with Share Point. If there's anything else I can provide related to the installation/configuration, let me know.
Coordinator
Jul 7, 2010 at 3:02 PM
Can you please try the following: 1. Go to SSRS SDK installation directory and open the file bin/SSRSReport.php 2. Comment out the line numbers starting from 193 to 200. //$context = stream_context_create($stream_conext_params); //$content = @file_get_contents($executionServiceUrl, false, $context); //if ($content === FALSE) //{ // throw new SSRSReportException("", // "Failed to connect to Reporting Service
Make sure " . // "that the url ($this->_BaseUrl) and credentials are correct!"); //} 3. Save the file and restart IIS. The goal is to check if file_get_contents is the call that fails. If it works with the above lines commented out we will then need to figure out why the file_get_contents fails. Thanks Claudio
Jul 20, 2010 at 4:38 PM

Hi, how are you, I tryng the same thing and I am getting this error

 

Caught exception: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://172.16.1.117/reportserver/ReportExecution2005.asmx?wsdl' : failed to load external entity "http://172.16.1.117/reportserver/ReportExecution2005.asmx?wsdl"

the code that I am running is this, and the account is a domain account

 

require_once 'SSRSReport.php';
try{     $rs = new SSRSReport(new Credentials("domain userid", "domain pass"),"http://172.16.1.117/reportserver/");
 }catch (Exception $e) {    echo 'Caught exception: ',  $e->GetMessage(), "\n";}

 

Any help will be appreciated

 

Thanks..

Jul 20, 2010 at 4:56 PM

Sorry for the late reply.  Commenting out lines 193 to 200 did allow for the other methods in the web service to be called successfully.  It does look like it is just the file_get_contents that is failing.

Jul 24, 2010 at 10:44 AM

I had the same problem as you I could solve it that way.

ensure you have this code in your php.ini

 

include_path = ".;C:\php-5.2.13-Win32\extras\SSRSReport\bin"

....................................................................................................

extension_dir = ".\ext"

......................................................................................................

 cgi.force_redirect = 0

.........................................................................

cgi.redirect_status_env = ENV_VAR_NAME

........................................................................

extension=php_curl.dll

extension=php_mcrypt.dll
extension=php_mhash.dll

 

extension=php_soap.dll

 

extension=php_xsl.dll

...............................................

 

app.conf

 

(; Credentials used to access the server
UID = "ESI-2BCAE3C156W\DIARBAKIRLI"
PASWD = "cherine"
SERVICE_URL = "http://esi-2bcae3c156w:8080/ReportServer"
DATA_SOURCE = "AdventureWorks2008")

 

 

 

lines is located at different locations must be sought and replace it with the correct code

 

if you have Quetions you tell me.

 

hope this helps

Jul 26, 2010 at 5:58 PM

I am having the exact same problem as eddygonzalez2000.

I commented out lines 193-200 in SSRSReport.php and I get the following message when I run:

php TestSSRSConnection.php /server:http://[SERVER NAME]/ReportServer /report:Administration/SubscriptionList /uid:[SERVER NAME]\PHPSSRS /pwd:[PASSWORD]


PHP Warning:  SoapClient::SoapClient(http://[SERVER NAME]/ReportServer/ReportExecution2005.asmx?wsdl): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized
 in /usr/share/php/SSRSReport.php on line 202
PHP Warning:  SoapClient::SoapClient(): I/O warning : failed to load external entity "http://[SERVER NAME]/ReportServer/ReportExecution2005.asmx?wsdl" in /usr/share/php/SSRSReport.php on line 202
PHP Fatal error:  SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://[SERVER NAME]/ReportServer/ReportExecution2005.asmx?wsdl' : failed to load external entity "http://[SERVER NAME]/ReportServer/ReportExecution2005.asmx?wsdl"
 in /usr/share/php/SSRSReport.php on line 202
PHP Fatal error:  Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://[SERVER NAME]/ReportServer/ReportExecution2005.asmx?wsdl' : failed to load external entity "http://[SERVER NAME]/ReportServer/ReportExecution2005.asmx?wsdl"
 in /usr/share/php/SSRSReport.php:202
Stack trace:
#0 /usr/share/php/SSRSReport.php(202): SoapClient->SoapClient('http://...', Array)
#1 /var/www/html_test/intranet/TestSSRSConnection.php(145): SSRSReport->SSRSReport(Object(Credentials), 'http://...')
#2 /var/www/html_test/intranet/TestSSRSConnection.php(207): TestSSRSConnection->TestConnection()
#3 {main}
  thrown in /usr/share/php/SSRSReport.php on line 202

 

One interesting thing to note, I am using SQL 2005 and I could find no place in rsreportserver.config to add the  <RSWindowsBasic/> tag. In fact when I tried to add it, the service would not start.  Everything else is exactly as the intructions stated. I added a local user to the server, gave them permissions on SQL Server and reporting services.

These are the only lines from rsreportserver.config that have authentication in them:

  <Authentication>
                       <Extension Name="Windows" Type="Microsoft.ReportingServices.Authentication.WindowsAuthentication, Microsoft.ReportingServices.Authorization"/>
  </Authentication>

I am using PHP Version 5.2.9 and the ini file longer uses the extension=[library].dll method. Instead you add them to /usr/share/php

Can someone please help me get up and running?

 

Jul 26, 2010 at 6:09 PM
Edited Jul 26, 2010 at 7:50 PM

mrkb80, In 2005, you change the authentication type under IIS not in the config file.

http://ssrsphp.codeplex.com/Thread/View.aspx?ThreadId=214076

Jul 26, 2010 at 6:47 PM

Thanks bhnat. So I changed those settings, restarted IIS and now I get the following results from:

php TestSSRSConnection.php /server:http://[SERVER NAME]/ReportServer /report:Administration/SubscriptionList /uid:PHPSSRS /pwd:[PASSWORD]


PHP Notice:  Undefined property: SoapFault::$detail in /usr/share/php/SSRSReport.php on line 687
Function ("LoadReport2") is not a valid method for this service

Usage:TestSSRSConnection.php /server:<report server uri> /report:<path of report> /uid:<user name> /pwd:<password> [/datasource:<name of datasource> /uid:<user name> /pwd:<password>]

It's just a notice rather an error, should I try and write a script to see if I can actually pull a report at this point?

Jul 26, 2010 at 8:03 PM

Nevermind. I answered my own question using these boards.

http://ssrsphp.codeplex.com/Thread/View.aspx?ThreadId=216221

Looks like 2005 needs a bit of adjustment to work.

Sep 19, 2010 at 7:55 PM
Edited Sep 19, 2010 at 7:56 PM

Hi All,

 

Delete @ on line 194 SSRSReport.php         $content = @file_get_contents($executionServiceUrl, false, $context);

When you delete i can see "Warning: file_get_contents(https://********/Reportserver/ReportExecution2005.asmx?wsdl) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in/home/***/SSRSReport/bin/SSRSReport.php on line 194

You can change security for this files or save this file dans import in local.

I'm prepare new GetReport.php compliant all navigator and added multi-filter.

 

Regards
neoray