2017-09-06 24 views
0

私たちはMVCアプリケーションを構築しています.SSLレポートをレンダリングする必要があるため、この目的でReporting Services Webサービスを使用しようとしています.SOA APIのドキュメントを探しています。this私はそのコードを複製して自分のコントローラーを作成しようとしましたが、私がActionResultを返さないことがわかるように、私は何を返すべきか分かりません。レポートサービスWebサービスMVCアプリケーション

私の質問は、MVCアプリケーションでReporting Service Webサービスを使用する最善の方法ですか? rs.Renderが成功した場合、私は何を返すべきですか?

public ActionResult soapReport(string path) 
    { 
     soapSSRS.ReportExecutionService rs = new soapSSRS.ReportExecutionService(); 
     rs.Url = "http://xxx.xxx.xxx.xx:xxxx/reportserver/ReportExecution2005.asmx"; 
     ; 
     rs.Credentials = new System.Net.NetworkCredential(
       ConfigurationManager.AppSettings["ssrs_user"].ToString(), 
       ConfigurationManager.AppSettings["ssrs_pass"].ToString(), 
       ConfigurationManager.AppSettings["ssrs_domain"].ToString()); 

     // Render arguments 
     byte[] result = null; 
     string reportPath = "/MyReportFolder/MyReport"; 
     string format = "MHTML"; 
     string historyID = null; 
     string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"; 

     // Prepare report parameter. 
     soapSSRS.ParameterValue[] parameters = new soapSSRS.ParameterValue[3]; 
     parameters[0] = new soapSSRS.ParameterValue(); 
     parameters[0].Name = "token"; 
     parameters[0].Value = "XxXxXxXxXxXxXx"; 

     DataSourceCredentials[] credentials = null; 
     string showHideToggle = null; 
     string encoding; 
     string mimeType; 
     string extension; 
     soapSSRS.Warning[] warnings = null; 
     ParameterValue[] reportHistoryParameters = null; 
     string[] streamIDs = null; 

     soapSSRS.ExecutionInfo execInfo = new soapSSRS.ExecutionInfo(); 
     soapSSRS.ExecutionHeader execHeader = new soapSSRS.ExecutionHeader(); 

     rs.ExecutionHeaderValue = execHeader; 

     execInfo = rs.LoadReport(reportPath, historyID); 

     rs.SetExecutionParameters(parameters, "en-us"); 
     String SessionId = rs.ExecutionHeaderValue.ExecutionID; 

     try 
     { 
      result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs); 
      execInfo = rs.GetExecutionInfo(); 
     } 
     catch (SoapException e) 
     { 
      Console.WriteLine(e.Detail.OuterXml); 
     } 
    } 

答えて

0

私がこれを行う方法は、2段階プロセスです。

最初のステップはレポートを生成することです。これはコードが行うものです。このステップ(AJAX呼び出しでステップが開始されます)は、ファイルレポートを一意の名前でローカルに保存し、生成レポートが成功したことを示すコード、ローカルファイル名、および必要なリモートファイル名でJsonResultを返します。

このJsonResultは、AJAX呼び出しの.successハンドラで解析され、別のアクションが呼び出されてファイルがダウンロードされます。これは良い例です:How To Create And Download File in ASP.Net MVC

関連する問題