我有一個SSRS(2008標準,而不是R2),所以我使用ReportExecution2005.asmx和ReportService2005.asmx來運行它們。嘗試訪問SQL Server報告服務的web服務時出現用戶認證問題
我們開發了一個可以通過webservice連接到SSRS的應用程序。它在我們的測試服務器上運行良好,但是現在我試圖在虛擬機上配置一個新的服務器,並且沒有辦法,每當應用程序嘗試連接到SSRS Web服務時,我都會得到一個未受保護的401。
這很奇怪,因爲如果我只將.asmx url放在客戶端工作站上的firefox中,它會提示我輸入用戶名密碼,我輸入它並獲得wsdl定義,所以我認爲訪問是正確的。
這裏是我的代碼:
public ReportGateway()
{
_rs = new ReportingService2005 { Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ReportGatewayUser"], ConfigurationManager.AppSettings["ReportGatewayPassword"]) };
_rs.Url = "http://MyMachine:80/ReportServer/ReportService2005.asmx";//?? I saw when I was debugging that it wasn't reading the value in the app.config, but keeping the url of the reference when I created it, so for my test of the moment, I hard-setted it
_rsExec = new ReportExecution2005.ReportExecutionService { Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ReportGatewayUser"], ConfigurationManager.AppSettings["ReportGatewayPassword"]) };
_rsExec.Url = "http://MyMachine:80/ReportServer/ReportExecution2005.asmx";//Same
GenerateReportList();
}
[MethodImpl(MethodImplOptions.Synchronized)]
private void GenerateReportList()
{
try
{
Dictionary<String, SRSSReport> reports = new Dictionary<String, SRSSReport>();
foreach (var children in _rs.ListChildren("/", true))
{
if (children.Type == ItemTypeEnum.Report)
{
SRSSReport report = new SRSSReport {Name = children.Name, Path = children.Path};
ReportParameter[] parameters = _rs.GetReportParameters(children.Path, null, false, null, null);
foreach (ReportParameter parameter in parameters)
report.Parameters.Add(new SRSSReportParameter {Name = parameter.Name, Type = _typeConverstion[parameter.Type]});
reports.Add(report.Path, report);
}
}
lock (_lockObject)
{
_reports = reports;
}
}catch(Exception ex)
{
_reports = new Dictionary<string, SRSSReport>();
Logger.Instance.Error("Error when contacting the reporting server", ex);
}
}
我完全地絕望了,現在,我已經在天找了一個解決方案,我不知道有什麼我可以做錯了。
你有一個想法/解決方案/ ...來幫助我嗎?
非常感謝你,任何幫助將非常感激。
我知道,其實我認爲我做了一個糟糕的配置。我刪除了SRSS的所有用戶並重新設置了它,並且它正在工作 – J4N