Class JasperServer::Client
In: lib/jasper_server/client.rb
Parent: Object

The client through which all report requests are sent to the JasperServer.

Methods

Public Class methods

Create a new instance of the client.

url :The URL of the JasperServer. This should look something like: ":/jasperserver/services/repository"
username :The username used to connect to the JasperServer.
password :The password used to connect to the JasperServer.

Public Instance methods

Request a report from the server based on the ReportRequest object you provide. Returns the report data.

For example if your request specifies PDF as the output format, PDF binary data will be returned.

  client = JasperServer::Client.new("http://example.com/jasperserver/services/repository",
                                    "jasperadmin", "secret!")
  request = JasperServer::Request.new("/example/my-report", "PDF", {'fruit' => 'apple'})
  pdf_data = client.request_report(request)
  File.open('/tmp/report.pdf', 'w') do |f|
    f.puts(pdf_data)
  end

For debugging purposes, try requesting output in CSV format, since request_report will then return an easily readable String.

[Validate]