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);
    }
  • 相关阅读:
    程序员达到高效率的一种境界 狼人:
    IBM夏然:软件产业对整个国家发展举足轻重 狼人:
    浅析Node.js:一个“编码就绪”服务器 狼人:
    eBay的Turmeric和VJet的源程序移到了GitHub上 狼人:
    程序员最常见的技术性误区 狼人:
    我不是一个工程师——我是一个软件开发者 狼人:
    【简讯】Adobe停止发布AIR for Linux版本 狼人:
    【赏析】15个非常棒的使用CSS3的设计组合 狼人:
    5款最好的免费Linux缓存系统 狼人:
    漫画:天堂里没有程序员! 狼人:
  • 原文地址:https://www.cnblogs.com/springsnow/p/9433968.html
Copyright © 2011-2022 走看看