zoukankan      html  css  js  c++  java
  • C#(99):Reporting Service编程----访问Web服务

    将报表服务器 Web 服务的引用添加到项目中后,下一步是创建 Web 服务代理类的实例。 然后,您可以通过调用代理类中的方法来访问 Web 服务的方法。 当你的应用程序调用这些方法时,代理类生成的代码Visual Studio处理你的应用程序和 Web 服务之间的通信。


    RS_hatl.ReportingService rs = new RS_hatl.ReportingService();
    //rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
    rs.Credentials = new System.Net.NetworkCredential("administrator", "ATit@2609`", "hzamtek");
    //rs.Url = "http://<Server Name>/reportserver/reportservice2010.asmx";  
    rs.Timeout = -1;
    // Render 参数
    byte[] result = null;
    string reportPath = "/YBB/APTB";
    string format = "pdf";
    string historyID = null;
    string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
    // 准备报表参数
    RS_hatl.ParameterValue[] parameters = new RS_hatl.ParameterValue[1];
    parameters[0] = new RS_hatl.ParameterValue();
    parameters[0].Name = "AgingTo";
    parameters[0].Value = this.TextBox1.Text;
    RS_hatl.DataSourceCredentials[] credentials = null;
    string showHideToggle = null;
    //输出参数
    string encoding;
    string mimeType;
    RS_hatl.ParameterValue[] reportHistoryParameters = null;
    RS_hatl.Warning[] warnings = null;
    string[] streamIDs = null;
    try
    {
        rs.SessionHeaderValue = new RS_hatl.SessionHeader();
        //呈现报表
        result = rs.Render("/YBB/APTB", format, historyID, devInfo, parameters, credentials, showHideToggle,
            out encoding, out mimeType, out reportHistoryParameters, out warnings, out streamIDs);
        Response.Write("Execution date and time: " + rs.SessionHeaderValue.ExecutionDateTime + "<br>");
    }
    catch (SoapException e)
    {
        Response.Write(e.Detail.OuterXml);
    }
    // Write the contents of the report to an MHTML file.
    try
    {
        string FilePath = rs.SessionHeaderValue.SessionId + "_APTB.pdf";
        FileStream stream = File.Create(Server.MapPath("pdf/") + rs.SessionHeaderValue.SessionId + "_APTB.pdf", result.Length);
        stream.Write(result, 0, result.Length);
        stream.Close();
        this.Label9.Text = "报表文件已经创建:<br><a href=" + "pdf/" + rs.SessionHeaderValue.SessionId + "_APTB.pdf" + "> 查看报表</a><br。";
        this.PrintWithDialog("http://192.168.1.10/FSReports/pdf/" + FilePath);
    }
    catch (Exception e)
    {
        Response.Write(e.Message);
    }
  • 相关阅读:
    学习 Apache FileMatchs 规则
    yii2 vendor/bower/jquery/dist not exist
    Ionic POST提交使用普通表单提交数据
    Yii2 在php 7.2环境下运行,提示 Cannot use ‘Object’ as class name
    Yii2 使用 npm 安装的包
    phpStorm 激活
    Chrome DNS_PROBE_FINISHED_NXDOMAIN
    Yii2 中使用ts
    Js 对 浏览器 的 URL的操作
    js 编码、解码与asp.net 编码、解码
  • 原文地址:https://www.cnblogs.com/springsnow/p/9433968.html
Copyright © 2011-2022 走看看