【发布时间】:2017-09-06 17:05:13
【问题描述】:
我们正在构建一个 MVC 应用程序,我们需要渲染一些 SSRS 报告,因此我们正在尝试为此目的使用 Reporting Services Web 服务,寻找一些我找到的 SOAP API 文档this,所以我尝试复制该代码并编写我自己的控制器,但正如您所见,我没有返回任何 ActionResult,我不知道应该返回什么。
所以我的问题是,在 MVC 应用程序中使用 Reporting Service Web 服务的最佳方式是什么?如果 rs.Render 成功,我应该返回什么?
public ActionResult soapReport(string path)
{
soapSSRS.ReportExecutionService rs = new soapSSRS.ReportExecutionService();
rs.Url = "http://xxx.xxx.xxx.xx:xxxx/reportserver/ReportExecution2005.asmx";
;
rs.Credentials = new System.Net.NetworkCredential(
ConfigurationManager.AppSettings["ssrs_user"].ToString(),
ConfigurationManager.AppSettings["ssrs_pass"].ToString(),
ConfigurationManager.AppSettings["ssrs_domain"].ToString());
// Render arguments
byte[] result = null;
string reportPath = "/MyReportFolder/MyReport";
string format = "MHTML";
string historyID = null;
string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
// Prepare report parameter.
soapSSRS.ParameterValue[] parameters = new soapSSRS.ParameterValue[3];
parameters[0] = new soapSSRS.ParameterValue();
parameters[0].Name = "token";
parameters[0].Value = "XxXxXxXxXxXxXx";
DataSourceCredentials[] credentials = null;
string showHideToggle = null;
string encoding;
string mimeType;
string extension;
soapSSRS.Warning[] warnings = null;
ParameterValue[] reportHistoryParameters = null;
string[] streamIDs = null;
soapSSRS.ExecutionInfo execInfo = new soapSSRS.ExecutionInfo();
soapSSRS.ExecutionHeader execHeader = new soapSSRS.ExecutionHeader();
rs.ExecutionHeaderValue = execHeader;
execInfo = rs.LoadReport(reportPath, historyID);
rs.SetExecutionParameters(parameters, "en-us");
String SessionId = rs.ExecutionHeaderValue.ExecutionID;
try
{
result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
execInfo = rs.GetExecutionInfo();
}
catch (SoapException e)
{
Console.WriteLine(e.Detail.OuterXml);
}
}
【问题讨论】:
标签: c# asp.net asp.net-mvc web-services reporting-services