我正在使用SSRS SDK for PHP
PHP版本5.4
网络服务器:Centos 6.4
MSSQL Server 2008 R2
define("UID", "*****\*****"); define("PASWD", "*****"); define("SERVICE_URL", "http://192.168.0.1/ReportServerURL/"); try { $ssrs_report = new SSRSReport(new Credentials(UID, PASWD), SERVICE_URL); } catch (SSRSReportException $serviceException) { echo $serviceException->GetErrorMessage() . "
"; }
当我尝试连接SSRS报告时,它会遇到以下错误:
Failed to connect to Reporting Service
Make sure that the url (http://192.168.0.1/ReportServerURL/) and credentials are correct!
可以通过浏览器访问相同的凭据和链接而没有问题.但是,通过SSRS SDK,它无法正常工作.
我在网上寻找解决方案,我发现使用该文件TestSSRSConnection.php
我可以获得更多细节,但我不知道如何使用它,我找不到任何关于它的文档.
$testSSRSConnection = new TestSSRSConnection("/192.168.0.1/TESTREPORT/ReportServerURL/*****\*****/*****"); $testSSRSConnection->Parse(); $testSSRSConnection->TestConnection();
测试它我得到以下错误:
Usage:TestSSRSConnection.php /server: /report: /uid: /pwd: [/datasource: /uid: /pwd:]
有些人想过如何在这个主题上前进?
更新
做一个var_export($http_response_header))
我有
array ( 0 => 'HTTP/1.1 401 Unauthorized', 1 => 'Content-Length: 0', 2 => 'WWW-Authenticate: Negotiate', 3 => 'WWW-Authenticate: NTLM', 4 => 'Date: Tue, 04 Mar 2014 22:13:58 GMT', 5 => 'Connection: close', )
Emilio Gort.. 6
问题出在身份验证类型上.
默认情况下,Reporting Services接受指定Negotiate和NTLM身份验证的请求.如果部署包括使用基本身份验证的客户端应用程序或浏览器,则必须将基本身份验证添加到支持的类型列表中.
为了得到标题响应,我在第193行的SSRSReport.php中添加了
if ($content === FALSE) { throw new SSRSReportException("", "
Failed to connect to Reporting Service
Make sure " . "that the url ($this->_BaseUrl) and credentials are correct!
" . var_export($http_response_header));//Line added by me to get the http header response }
输出:
array ( 0 => 'HTTP/1.1 401 Unauthorized', 1 => 'Content-Length: 0', 2 => 'WWW-Authenticate: Negotiate', 3 => 'WWW-Authenticate: NTLM', 4 => 'Date: Tue, 04 Mar 2014 22:13:58 GMT', 5 => 'Connection: close', ) Failed to connect to Reporting Service Make sure that the url (http://192.168.0.1/ReportServerURL/) and credentials are correct!
向SSRS添加基本身份验证可解决问题.
配置报表服务器以使用基本身份验证
1-在文本编辑器中打开RSReportServer.config.
2-找到Authentication
.
3-复制最符合您需求的以下XML结构之一.第一个XML结构提供了占位符,用于指定所有元素,这将在下一节中介绍:
3 true
如果使用默认值,则可以复制最小元素结构:
4-将其粘贴到现有条目上.
如果您使用多种身份验证类型,请仅添加RSWindowsBasic元素,但不要删除RSWindowsNegotiate,RSWindowsNTLM或RSWindowsKerberos的条目.
要支持Safari浏览器,您无法将报表服务器配置为使用多种身份验证类型.您必须仅指定RSWindowsBasic并删除其他条目.
请注意,您不能将Custom与其他身份验证类型一起使用.
5-为对您的环境有效的值替换空值或使用值替换空值.
6-保存文件.
7-如果您配置了横向扩展部署,请对部署中的其他报表服务器重复这些步骤.
8-重新启动报表服务器以清除当前打开的所有会话.