Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将SSRS报告嵌入网页而不使用报告查看器_C#_Reporting Services_Ssrs 2008 - Fatal编程技术网

C# 将SSRS报告嵌入网页而不使用报告查看器

C# 将SSRS报告嵌入网页而不使用报告查看器,c#,reporting-services,ssrs-2008,C#,Reporting Services,Ssrs 2008,我有一个用VS2008&C编写的现有web应用程序,需要将SSRS报告嵌入到网页中。数据库/SSRS服务器位于非现场和防火墙后面,只能通过IP从单独的web服务器盒访问。数据库框正在运行SQL Server 2008R2我无法将报表查看器控件用作解决方案。 我尝试了SSRSWeb服务和URL访问。调用LoadReport和/或Render方法时,使用web服务会引发错误。使用URL访问会为报表项的路径生成错误。我尝试了许多不同的代码示例和方法来解决这个问题,但没有成功。有没有人有我可以用来让它工

我有一个用VS2008&C编写的现有web应用程序,需要将SSRS报告嵌入到网页中。数据库/SSRS服务器位于非现场和防火墙后面,只能通过IP从单独的web服务器盒访问。数据库框正在运行SQL Server 2008R2我无法将报表查看器控件用作解决方案。

我尝试了SSRSWeb服务和URL访问。调用LoadReport和/或Render方法时,使用web服务会引发错误。使用URL访问会为报表项的路径生成错误。我尝试了许多不同的代码示例和方法来解决这个问题,但没有成功。有没有人有我可以用来让它工作的工作代码示例

理想情况下,我希望通过某种方式从调用返回HTML,然后将其放入DIV标记或iframe中

这是一个样本,它对我有用

网页配置


输出类型报告格式,即Pdf、图像、Excel、Ffd

deviceInfo包含基于 报告格式

reportPath包含SSRS服务器“/xxx/datarecord表”上的报告路径

private SsrsResponse ExecuteSsrsReport(字符串reportPath,IEnumerable参数,
字符串输出类型,字符串设备信息)
{
使用(var rs=new ReportExecutionServiceSoapClient())
{
if(rs.ClientCredentials!=null)
{
rs.ClientCredentials.Windows.ClientCredential=GetReportingCredentials();
rs.ClientCredentials.Windows.AllowedImpersonationLevel=
System.Security.Principal.TokenImpersonationLevel.Impersonation;
}
字节[]结果;
警告[]警告;
字符串[]流线;
ParameterValue[]ParameterValue=
parameters.Select(p=>newparametervalue{Name=p.Key,Value=p.Value}).ToArray();
ExecutionInfo ExecutionInfo;
ServerInfoHeader服务器InfoHeader;
ExecutionHeader ExecutionHeader=
rs.LoadReport(null,reportPath,null,out serverInfoHeader,out execInfo);
rs.SetExecutionParameters(execHeader,null,参数值,“en-us”,out-execInfo);
字符串扩展,mimeType,编码;
rs.Render(execHeader,null,outputType,deviceInfo,
输出结果、输出扩展、输出mimeType、输出编码、输出警告、输出流ID);
返回新的SsrsResponse(结果、扩展名、mimeType、编码);
}
}
专用网络凭据GetReportingCredentials()
{
返回新的网络凭据(
ConfigurationManager.AppSettings[“ReportingUserName”],
ConfigurationManager.AppSettings[“ReportingPassword”],
ConfigurationManager.AppSettings[“ReportingDomain”]
);
}

尝试在iframe中调用报表的同一URI。

您如何尝试使用web服务以及引发了哪些错误?如果我设置凭据,然后调用LoadReport(“/My+Reports/the reportname”,historyID),我已经添加了一个web引用,返回错误:“/My+Reports/the reportname”项的路径无效。完整路径长度必须小于260个字符;其他限制也适用。如果报表服务器处于本机模式,则路径必须以斜杠开头。-->如果我将路径切回“/my+reports”,并将任何报告名称添加到生成该错误的路径中,我就能够成功加载我的报告列表。您是否尝试直接加载报告而不是我的报告?我的报告是特定于用户的,可能会产生线索。ExecutionInfo ei=re.LoadReport(“报告名”,historyID);这将返回相同的错误。缺少reportname前面的前导/前导。ExecutionInfo ei=re.LoadReport(“/reportname”,historyID);返回错误:找不到项“/reportname”。->我相当肯定,如果跨不同域访问iFrame,iFrame将无法工作——web服务跨域问题。但是,如果这不是一个可以工作的项目问题,则在“使用”行上,IDE会突出显示ReportExecutionServiceSoapClient作为找不到类型或命名空间。与回油管中的SSR响应相同。不知道为什么。我修复了ReportExecutionServiceSoapClient,我使用的是Web引用而不是服务引用。仍然无法找出返回线路中的“SsrsResponse”有什么问题。任何人
<!-- Reporting -->
        <add key="ReportingUserName" value="xxxxx\xxxx" />
        <add key="ReportingPassword" value="xxxxxxxxx" />
        <add key="ReportingDomain" value="xxxxxxx" />


     <endpoint address="http://xxxxxx/ReportServer/ReportExecution2005.asmx" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfig" contract="SSRS.ReportExecutionServiceSoap" name="ReportExecutionServiceSoap" />

     <!-- Binding for Reporting Services over HTTP -->
            <binding name="basicHttpBindingConfig" allowCookies="true" maxReceivedMessageSize="52428800" sendTimeout="00:10:00">
              <security mode="TransportCredentialOnly">
                <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
              </security>
            </binding>
  private SsrsResponse ExecuteSsrsReport(string reportPath, IEnumerable<KeyValuePair<string, string>> parameters,
        string outputType, string deviceInfo)
    {
        using (var rs = new ReportExecutionServiceSoapClient())
        {
            if (rs.ClientCredentials != null)
            {
                rs.ClientCredentials.Windows.ClientCredential = GetReportingCredentials();
                rs.ClientCredentials.Windows.AllowedImpersonationLevel =
                    System.Security.Principal.TokenImpersonationLevel.Impersonation;
            }

            byte[] result;
            Warning[] warnings;
            string[] streamIds;

            ParameterValue[] parameterValues =
                parameters.Select(p => new ParameterValue { Name = p.Key, Value = p.Value }).ToArray();

            ExecutionInfo execInfo;
            ServerInfoHeader serverInfoHeader;

            ExecutionHeader execHeader =
                rs.LoadReport(null, reportPath, null, out serverInfoHeader, out execInfo);
            rs.SetExecutionParameters(execHeader, null, parameterValues, "en-us", out execInfo);

            string extension, mimeType, encoding;
            rs.Render(execHeader, null, outputType, deviceInfo,
                out result, out extension, out mimeType, out encoding, out warnings, out streamIds);

            return new SsrsResponse(result, extension, mimeType, encoding);
        }
    }

private NetworkCredential GetReportingCredentials()
{
    return new NetworkCredential(
        ConfigurationManager.AppSettings["ReportingUserName"],
        ConfigurationManager.AppSettings["ReportingPassword"],
        ConfigurationManager.AppSettings["ReportingDomain"]
    );
}