I am creating a C# web application to save an SSRS report as a pdf file on my local machine.
I added the ReportService web reference as RS2005 and ReportExecution2005 web reference as RE2005.
http://myServer/ReportServer_DEVPROJECT/ReportExecution2005.asmx?WSDL
http://myServer/ReportServer_DEVPROJECT/ReportService2005.asmx?WSDL
I created the following function SaveReport that is called on button click. My report can be accessed on the report server with the following url:
http://myServer/Reports_DEVPROJECT/Pages/Report.aspx?ItemPath=%2fData+Mgmt%2fSample+Letter
On the Report Manager home page the report link appears as "SAMPLE LETTER".
It is deployed in the DataMgmt folder on the Report Manager.
It uses a data source called "DS Letter" with option "Credentials stored securely in the report server"
My application gets compiled, but I get the following run time error:
Error: Soap exception unhandeled by user code. The item '/DataMgmt/Sample Letter' cannot be found. ---> Microsoft.ReportingService
I added the ReportService web reference as RS2005 and ReportExecution2005 web reference as RE2005.
http://myServer/ReportServ
http://myServer/ReportServ
I created the following function SaveReport that is called on button click. My report can be accessed on the report server with the following url:
http://myServer/Reports_DE
On the Report Manager home page the report link appears as "SAMPLE LETTER".
It is deployed in the DataMgmt folder on the Report Manager.
It uses a data source called "DS Letter" with option "Credentials stored securely in the report server"
My application gets compiled, but I get the following run time error:
Error: Soap exception unhandeled by user code. The item '/DataMgmt/Sample Letter' cannot be found. ---> Microsoft.ReportingService
Please check my code and let me know what I can do to run this successfully. Once this is done, I would like to get help with passing a parameter (memberID) to the generate report for that member, through this application.
Thank You in advance for your help.
public static void SaveReport() { RS2005.ReportingService2005 rs; RE2005.ReportExecutionService rsExec; // Create a new proxy to the web service rs = new RS2005.ReportingService2005(); rsExec = new RE2005.ReportExecutionService(); // Authenticate to the Web service using Windows credentials rs.Credentials = System.Net.CredentialCache.DefaultCredentials; rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials; rs.Url = "http://myServer/ReportServer_DEVPROJECT/ReportService2005.asmx"; rsExec.Url = "http://myServer/ReportServer_DEVPROJECT/ReportExecution2005.asmx"; string historyID = null; string deviceInfo = null; string format = "pdf"; Byte[] results; string encoding = String.Empty; string mimeType = String.Empty; string extension = String.Empty; RE2005.Warning[] warnings = null; string[] streamIDs = null; string fileName = @"c:\temp\samplerHAPeport.pdf"; string _reportName = @"/DataMgmt/Sample HAP Letter"; string _historyID = null; bool _forRendering = false; RS2005.ParameterValue[] _values = null; RS2005.DataSourceCredentials[] _credentials = null; RS2005.ReportParameter[] _parameters = null; try { _parameters = rs.GetReportParameters(_reportName, _historyID, _forRendering, _values, _credentials); RE2005.ExecutionInfo ei = rsExec.LoadReport(_reportName, historyID); RE2005.ParameterValue[] parameters = new RE2005.ParameterValue[1]; if (_parameters.Length > 0) { //parameters[0] = new RE2005.ParameterValue(); //parameters[0].Label = ""; //parameters[0].Name = ""; //parameters[0].Value = ""; } rsExec.SetExecutionParameters(parameters, "en-us"); results = rsExec.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs); using (FileStream stream = File.OpenWrite(fileName)) { stream.Write(results, 0, results.Length); } } catch (Exception ex) { throw ex; } } protected void BtnGenReport_Click(object sender, EventArgs e) { SaveReport(); }