Rails3.2 SSRS 和 SavonRD
Rails 3.2 SSRS and SavonRD
我正在将我的 Rails 3.2 应用程序与 SSRS 集成,以便使用 Savonrb 对 SSRS 网络服务进行 Soap 调用进行报告。终于一切正常,我可以成功进行以下调用:
- 加载报告
- 设置执行参数
- 渲染
渲染调用采用格式参数(在我的例子中是 PDF)和 returns 一个 XML 响应。我认为调用会导致报告以 pdf 格式呈现,但事实并非如此。我需要如何处理响应对象才能呈现报告?
代码如下:
response = @client.call(:load_report, message: {report: "/path/to/report"} )
response = @client.call(:set_execution_parameters, message: { "Parameters" => param1} )
response = @client.call(:render, message: {"Format" => "PDF"})
谢谢!
答案是我需要获取从 render 调用返回的 xml 字符串并将其解码为 Base64,将其写入文件,然后用户 send_file 流式传输文件到浏览器。这现在有效,代码如下:
response = @newClient.call(:render, message: {"Format" => "PDF"})
@results = response.to_hash
@report = @results[:render_response][:result]
@extension = @results[:render_response][:extension]
@mime_type = @results[:render_response][:mime_type]
@report_name = "MyReportName.pdf" # this should be dynamically generated from a param passed in the call to run_report
File.open(@report_name, "wb+") do |f|
f.puts Base64.decode64(@report)
end
@file = File.open(@report_name, 'r')
send_file @file, :filename => @report_name, :type => "application/pdf; charset=utf-8", :disposition => "attachment"
我正在将我的 Rails 3.2 应用程序与 SSRS 集成,以便使用 Savonrb 对 SSRS 网络服务进行 Soap 调用进行报告。终于一切正常,我可以成功进行以下调用:
- 加载报告
- 设置执行参数
- 渲染
渲染调用采用格式参数(在我的例子中是 PDF)和 returns 一个 XML 响应。我认为调用会导致报告以 pdf 格式呈现,但事实并非如此。我需要如何处理响应对象才能呈现报告?
代码如下:
response = @client.call(:load_report, message: {report: "/path/to/report"} )
response = @client.call(:set_execution_parameters, message: { "Parameters" => param1} )
response = @client.call(:render, message: {"Format" => "PDF"})
谢谢!
答案是我需要获取从 render 调用返回的 xml 字符串并将其解码为 Base64,将其写入文件,然后用户 send_file 流式传输文件到浏览器。这现在有效,代码如下:
response = @newClient.call(:render, message: {"Format" => "PDF"})
@results = response.to_hash
@report = @results[:render_response][:result]
@extension = @results[:render_response][:extension]
@mime_type = @results[:render_response][:mime_type]
@report_name = "MyReportName.pdf" # this should be dynamically generated from a param passed in the call to run_report
File.open(@report_name, "wb+") do |f|
f.puts Base64.decode64(@report)
end
@file = File.open(@report_name, 'r')
send_file @file, :filename => @report_name, :type => "application/pdf; charset=utf-8", :disposition => "attachment"