【问题标题】:SSRS Web Service Render Report HTTP 503 Server ErrorSSRS Web 服务呈现报告 HTTP 503 服务器错误
【发布时间】:2016-12-21 17:48:48
【问题描述】:

大家好。我尝试使用带有此类代码的 ssrs Web 服务。

using System.Collections.Generic;
using System.Linq;
using SSRS = ReportConnector.SSRS;
using SSRSExec = ReportConnector.SSRSExec;
using System.Net;

namespace ReportSoapConnection
{
    public static class ReportRunner
    {
        public static byte[] Report(string serverName, string reportLocation, NetworkCredential aCred, string aConnection, string reportformat, Dictionary<string, string> ReportParams)
        {
            SSRS.ReportingService2010 rptService = new SSRS.ReportingService2010();
            SSRSExec.ReportExecutionService rptExecute = new SSRSExec.ReportExecutionService();
            try
            {
                rptService.Url = serverName + "/ReportServer/ReportService2010.asmx";
                rptExecute.Url = serverName + "/ReportServer/ReportExecution2005.asmx";

                rptService.Credentials = aCred;
                rptService.Timeout = 3000000;
                rptExecute.Credentials = aCred;
                rptExecute.Timeout = 3000000;

                SSRSExec.ExecutionInfo execInfo = rptExecute.LoadReport(reportLocation, null);

                byte[] reportBytes = null;
                try
                {
                    SSRS.ItemParameter[] itemparams = rptService.GetItemParameters(reportLocation, null, true, null, null);
                    SSRSExec.ParameterValue[] execParameterValues = new SSRSExec.ParameterValue[itemparams.Count()];
                    int paramIndex = 0;
                    if (itemparams != null)
                    {
                        foreach (var rp in itemparams)
                        {
                            SSRSExec.ParameterValue assignThis = new SSRSExec.ParameterValue();
                            assignThis.Label = rp.Name;
                            assignThis.Name = rp.Name;
                            if (ReportParams.ContainsKey(rp.Name))
                                assignThis.Value = ReportParams[rp.Name];
                            else 
                            {
                                assignThis.Value = null;
                            }
                            execParameterValues[paramIndex++] = assignThis;
                        }
                        rptExecute.SetExecutionParameters(execParameterValues, "ru-Ru");
                    }
                    string mimeType;
                    string extention;
                    string[] streamIDs;
                    string encoding;
                    SSRSExec.Warning[] warnings;
                    reportBytes = rptExecute.Render(reportformat,   // report output format
                                                            null,
                                                            out extention,
                                                            out mimeType,
                                                            out encoding,
                                                            out warnings,
                                                            out streamIDs);
                }
                finally
                {
                }
                return reportBytes;
            }
            //  throw new Exception(string.Format("{0}, Server {1}, RL = {2} Source = {3} TargetSite = {4} ST = {5}", E.Message, serverName, reportLocation, E.Source, E.TargetSite, E.StackTrace), E);
            finally
            {
                rptService.Dispose();
                rptExecute.Dispose();
            }
        }
    }
}

class Program
{


    static void Main(string[] args)
    {
        Thread th = null;
        for (int i=0; i< 50; i++)
        {
            th = new Thread(Run);
            th.Start();
        }
        Console.WriteLine();
        Console.WriteLine("Press <ENTER> to terminate client.");
        Console.ReadKey();
    }

    static void Run()
    {
        ReportRunner.Report("http://srv-test", "/Dx/Reports/Cln/Inventory",
            new NetworkCredential("user", "pwd", "VC"), null, "PDF",
            new Dictionary<string, string> { { "FId", "1" }, { "Report_Id", "24921" }, { "Date", "2016-10-04" } });
    }
}

rptExecute.Render - 抛出异常 System.Web.Services.dll 中出现“System.Net.WebException”类型的未处理异常 HTTP 503:服务器错误。

如果我不使用多线程一切正常。我做错了什么? 谢谢你的帮助。

【问题讨论】:

    标签: c# reporting-services


    【解决方案1】:

    更改 rsreportserver.config 中的以下键值以执行并发请求。

    默认值为 20

    <Add Key="MaxActiveReqForOneUser" Value="20"/>
    

    【讨论】:

    • 谢谢。这有助于避免错误 503。但我遇到了另一个错误:所有请求和处理都需要连接到数据库。 ---> System.InvalidOperationException:超时已过期。在从池中获取连接之前超时时间已过。这可能是因为所有池连接都在使用中并且达到了最大池大小。我尝试在报告数据源中将 Max Pool Size 设置为 5000,但似乎 SSRS 忽略了此参数。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    相关资源
    最近更新 更多