ssrs report web service to save report as pdf throws error Soap exception unhandeled by user code
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 s.Diagnostics.Utilities.ItemNotFoundException: The item '/DataMgmt/Sample Letter' cannot be found. 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(); }
July 24th, 2012 8:23pm

Hello Devster, Thank you to post your question on TechNet forum. After reviewing the whole post, I have a question to you. You can access the report via the link, http://myServer/Reports_DEVPROJECT/Pages/Report.aspx?ItemPath=%2fData+Mgmt%2fSample+Letter. From the URL, I can see that the report is located at: /Data Mgmt/Sample Letter, instead of /DataMgmt/Sample Letter. In addition, I found that the target report is "/DataMgmt/Sample HAP Letter" instead of "/DataMgmt/Sample Letter" as the error described. I am not sure whether you post out the correct code segment. Please check the above things on your side, and hope it is helpful to you. Regards, EdwardEdward Zhu TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
July 26th, 2012 1:49am

OMG! Thank you Edward!. That helped It was the space needed between Data Mgmt (not DataMgmt). Great. Thanks.
July 26th, 2012 9:45am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics