SSRS报告直接执行,但WCF ReportExporter.Export方法返回null Result且没有错误

时间:2015-11-12 19:00:50

标签: wcf reporting-services

我有一个托管在SQL Server 2012 SSRS中的报告,它通过浏览器执行得很好。我正在尝试使用WCF作为ASP.Net Web项目中SSRS 2005 asmx的服务引用来运行它,并使用ReportExporter.Export()方法将其作为PDF返回;但是,它根本没有返回结果,并且warnings数组为空。那么,我该如何解决问题,看看困难在哪里?我没有在SSRS日志文件中发现任何错误,即使我将其设置为详细;我也没有在标准SQL日志中发现任何错误。

这是我的代码:

注意:调用ReportExporter.Export(..)是一个方法,它将webServiceProxy的执行封装到服务引用中。

{ 
    IList<SSRS_Reports.ParameterValue> parameters = new List<SSRS_Reports.ParameterValue>();
    parameters.Add(new SSRS_Reports.ParameterValue { Name = "paramId", Value = _paramId.ToString() }); }

    byte[] result = null;

    string extension = string.Empty;
    string mimeType = string.Empty;
    string encoding = string.Empty;
    string reportName = "/baseFolder/ReceiptReport";

    SSRS_Reports.Warning[] warnings = null;

    string[] streamIDs = null;
    string uN = ConfigurationManager.AppSettings["rptUName"].ToString();
    string uP = ConfigurationManager.AppSettings["rptPWD"].ToString();
    string uD = ConfigurationManager.AppSettings["rptDomain"].ToString();

    //NOTE: the call "ReportExporter.Export(..) is to a  method that encapsulates the execution of the webServiceProxy to the Service Reference.
   ReportExporter.Export("ReportExecutionServiceSoap",
                         new System.Net.NetworkCredential(uN, uP, uD),
                         reportName,
                         parameters.ToArray(),
                         ExportFormat.PDF,
                         out result,
                         out extension,
                         out mimeType,
                         out encoding,
                         out warnings,
                         out streamIDs);

   if (result != null)
   {
       //create a file and then show in browser
       _mPDFFile = randomName() + ".pdf";
       _mPDFPath = HttpRuntime.AppDomainAppPath + "\\pdf\\" + _mPDFFile;

       //clear files older than today
       Lib.FileManager.ManageFiles(HttpRuntime.AppDomainAppPath + "\\pdf", "*.pdf", -1);

       if (File.Exists(_mPDFPath)) 
       { 
           File.Delete(_mPDFPath);
       }

       FileStream stream = File.Create(_mPDFPath, result.Length);
       stream.Write(result, 0, result.Length);
       stream.Close();

       return true;
    }
}

0 个答案:

没有答案