2016-07-28 5 views
1

Savon 2.11.1を使用してRRSをSql Server Reports Services(SSRS)に統合しようとしています。私はReportServicesExecution2005 WSDLを使用しています。私が持っている問題は、クライアントがインスタンス化された後にsoapヘッダにsession_idを追加する必要があるということです。これは、クライアントがload_reportを呼び出すと、session_idがSSRSによって生成されるためです。Savon 2.11.1クライアントがインスタンス化された後にsoapヘッダーを設定するRails + SSRS

client = Savon.client(wsdl: "https://somewsdl.asmx?wsdl", basic_auth: ["user", "pass"]) 

この呼び出しは応答SESSION_IDを返す:

response = client.call(:load_report, message: {report: "path/to/report"}) 

SOAPヘッダは、この呼び出しが行われるときにクライアントにSESSION_IDを含む必要がある:

client.call(:set_execution_parameters, message: { report: "path/to/report", parameters: params } ) 

はこれを試みたがそれは動作しませんでした:

client.call(:set_execution_parameters, soap_header: {"session_id" => @session_id}, message: { report: "path/to/report", parameters: params } ) 

次のエラーが表示されます。

(soap:Client) The session identifier is missing. A session identifier is required for this operation. ---> Microsoft.ReportingServices.Diagnostics.Utilities.MissingSessionIdException: The session identifier is missing. A session identifier is required for this operation.

ありがとうございました。

答えて

0
私が見つけた解決策は、(不格好中)サボン経由で新しいクライアントを作成し、既存のクライアント値を渡すことでした

プラス新しいexecution_id/session_Idをコンストラクタに追加します。これはトリックでした。以下のコード例。

初期サボンクライアント:

@exeClient = Savon.client(wsdl: "some_wsdl.asmx?wsdl", basic_auth: ["user", "pass"], 
convert_request_keys_to: :camelcase, soap_header: {"execution_id" => ""}) 

コールload_report execution_idを取得する:

@data = @exeClient.call(:load_report, message: {report: "/path/to/report"}) 

アクセスexecution_id:

@report = @data.to_hash 

@execution_id = @report[:load_report_response][:execution_info][:execution_id] 

を経由してレポートを実行するためのアクセス権を持つ新しいクライアントを作成します。実行ID:

@newClient = Savon.client(wsdl: "/path/to/report/wsdl", basic_auth: ["user", "pass"], 
:soap_header => {:"tns:TrustedUserHeader" => {"tns:UserName"=> "" , "tns:UserToken" => ""}, :"tns:ExecutionHeader" => {"tns:ExecutionID" => @execution_id}}) 

paramsハッシュを作成します。

param1 = { :Parameter_value =>{ 
    :"Name" => "nameOfParam", 
    :"Value" => current_user.company_id 
    } 
} 

コールsetExecutionParameters:

response = @newClient.call(:set_execution_parameters, message: { "Parameters" => param1}) 

今それが動作します。 Savonで名前空間を指定する方法が重要であることに注意してください。正しく実行しないと、一部のタグで名前空間が指定されません。石鹸呼び出しを失敗させます。

+0

また、 "TrustedUserHeader"とすべてのサブタグは、空白であるかどうかにかかわらず、この作業を行う必要があることを指摘したいと思います。 – user2967603

0

あなたは

response = client.call(:set_execution_parameters, :soap_header => { :session_id => sid }) 

乾杯

のようなセッションIDを渡すためにSOAP_HEADERハッシュを使用する必要があります
+0

これは、ローカルとサバンパスのグローバルにあるsoap_headerをclient.rdに設定します。あなたのソリューションを試しても、私はまだ同じエラーが発生しており、session_idはsoap_headerでまだ空です。 – user2967603

関連する問題