Hi,
I am a junior dynamics developer and I am trying to retrieve a report from SSRS in a C# plugin.
I used ReportExecution2005.asmx as a web reference to generate the classes necessary for this task.
I pass the credentials, report path and the server URL through a json using Unsecure Config.
The problem is that I receive the following error:
System.Web.Services.Protocols.SoapException: The item '/reports_crm365/report/testv9_MSCRM/ContactList' cannot be found. ---> Microsoft.ReportingServices.Diagnostics.Utilities.ItemNotFoundException: The item '/reports_crm365/report/testv9_MSCRM/ContactList' cannot be found.
The error occurs when I am trying to load report using the LoadReport method of the ReportExecutionService class.
I am really sure that the report path is correct. My security roles in SSRS are the following:
| Browser, Publisher, Publisher for Microsoft CRM, Report Builder |
This is the code of my getReport method, where ReportAttachment is a class where I deserialize the JSON from unsecure config:
public static class ReportTools
{
public static byte[] GetReport(ReportAttachment reportInfos)
{
byte[] report = null;
string encoding;
string mimeType;
string extension;
Warning[] warnings = null;
string[] streamIDs = null;
string historyId = null;
string debug = "";
string reportPath = reportInfos.reportPath;
string reportServerUrl = reportInfos.reportServer;
string reportConnectionUser = reportInfos.ssrsUser;
string password = reportInfos.ssrsPass;
string reportConnectionDomain = reportInfos.domainName;
if (string.IsNullOrEmpty(reportServerUrl) || string.IsNullOrEmpty(reportPath)
|| string.IsNullOrEmpty(reportConnectionUser) || string.IsNullOrEmpty(password)
|| string.IsNullOrEmpty(reportConnectionDomain)) return report;
try
{
NetworkCredential credentials = new NetworkCredential(reportConnectionUser, password, reportConnectionDomain);
ReportExecutionService reportExecutionService = new ReportExecutionService();
reportExecutionService.PreAuthenticate = true;
reportExecutionService.Credentials = credentials;
reportExecutionService.Url = reportServerUrl;
ExecutionHeader execHeader = new ExecutionHeader();
reportExecutionService.ExecutionHeaderValue = execHeader;
ExecutionInfo execInfo = new ExecutionInfo();
execInfo = reportExecutionService.LoadReport(reportPath, historyId);
string sessionId = reportExecutionService.ExecutionHeaderValue.ExecutionID;
report = reportExecutionService.Render("PDF",
@"False",
out extension,
out encoding,
out mimeType,
out warnings,
out streamIDs);
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException("THE RAPORT COULD NOT BE RETRIEVED " ex.Message);
}
return report;
}
}