2016-10-05 8 views
0

おはようございます。私はそのようなコードでssrs Webサービスを使用しようとします。サーバーエラー: -SSRS WebサービスレンダリングレポートHTTP 503サーバーエラー

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は HTTP 503 System.Web.Services.dllに発生した例外 型 'System.Net.WebException' の未処理の例外がスローされます。

マルチスレッドを使用しない場合は、すべてokです。私が間違ったことは何ですか? ありがとうございます。

答えて

1

rsreportserver.configで次のキーの値を変更して同時リクエストを行います。

デフォルト値は20

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

でいただきありがとうございます。これはエラー503を避けるのに役立ちました。しかし別のエラーが発生しました: すべての要求と処理にデータベースへの接続が必要です。 ---> System.InvalidOperationException:タイムアウトが切れました。プールから接続を取得する前にタイムアウト期間が経過しています。これは、プールされたすべての接続が使用中で、プールの最大サイズに達したために発生した可能性があります。私はレポートのデータソースでMax Pool Sizeを5000に設定しようとしましたが、SSRSはこのパラメータを無視しているようです。 – Bkmz