Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 4th, 2012  |  syntax: None  |  size: 2.04 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. User auth problem when trying to access to the SQL Server Reporting service's webservice
  2. public ReportGateway()
  3.     {
  4.         _rs = new ReportingService2005 { Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ReportGatewayUser"], ConfigurationManager.AppSettings["ReportGatewayPassword"])  };
  5.         _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
  6.         _rsExec = new ReportExecution2005.ReportExecutionService { Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ReportGatewayUser"], ConfigurationManager.AppSettings["ReportGatewayPassword"]) };
  7.         _rsExec.Url = "http://MyMachine:80/ReportServer/ReportExecution2005.asmx";//Same
  8.         GenerateReportList();
  9.     }
  10.     [MethodImpl(MethodImplOptions.Synchronized)]
  11.     private void GenerateReportList()
  12.     {
  13.         try
  14.         {
  15.             Dictionary<String, SRSSReport> reports = new Dictionary<String, SRSSReport>();
  16.             foreach (var children in _rs.ListChildren("/", true))
  17.             {
  18.                 if (children.Type == ItemTypeEnum.Report)
  19.                 {
  20.                     SRSSReport report = new SRSSReport {Name = children.Name, Path = children.Path};
  21.                     ReportParameter[] parameters = _rs.GetReportParameters(children.Path, null, false, null, null);
  22.                     foreach (ReportParameter parameter in parameters)
  23.                         report.Parameters.Add(new SRSSReportParameter {Name = parameter.Name, Type = _typeConverstion[parameter.Type]});
  24.                     reports.Add(report.Path, report);
  25.                 }
  26.             }
  27.             lock (_lockObject)
  28.             {
  29.                 _reports = reports;
  30.             }
  31.         }catch(Exception ex)
  32.         {
  33.             _reports = new Dictionary<string, SRSSReport>();
  34.             Logger.Instance.Error("Error when contacting the reporting server", ex);
  35.         }
  36.     }