JasperServer4r Library

jasperserver4r is a ruby library for utilising the JasperServer web services API. jasperserver4r allows you to use all the methods defined by the report scheduling service. This library was developed and tested against JasperServer v3.5.0 so it may not work with earlier versions. Support for the repository service is under development. Documentation and comments are a work in progress.

Useful Web Resources

Installation

Install from rubyforge:

$ gem install jasperserver4r

The following gem libraries are required:

  • soap4r v1.5.8

  • httpclient v2.1.2 or greater

Using the client library

Basic example

It’s pretty easy to use. See docs.rubygems.org/read/chapter/3#page70 for how to set the rubygem environment. Then:

require 'jasperserver4r'
client = JasperServer::API.new( username, password )
schedule_service = client.get_report_scheduler_service( endpoint url )
scheduled_jobs = schedule_service.getAllJobs

creates a driver for the JasperServer web services API and retrieves a list of all schedules jobs currently defined in the JasperServer repository. Username and password are valid JasperServer portal credentials. The

get_report_scheduler_service endpoint url defaults to localhost:8080/jasperserver/services/ReportScheduler

Will be adding more examples asap. Check out the tests for sample usage of each available operation. The web services guide mentioned above is a good resource for detailed descriptions of available operations.

Logging

It is often useful to see a trace of the raw SOAP XML being sent and received. The quickest way of achieving this when debugging your application is by setting the JASPERSERVER4R_DEBUG environment variable to TRUE; e.g. in the bash shell:

$ export JASPERSERVER4R_DEBUG=TRUE

or from your Ruby code:

ENV['JASPERSERVER4R_DEBUG'] = 'TRUE'

This will output the SOAP XML to stderr, which will usually show up in your terminal window.

There’s also the option of logging requests and XML to files. In order to enable this, you should use the write_to_file method of the loggers inside your JasperServer::API object:

client = JasperServer::API.new
client.xml_logger.log_to_file

This logs the full SOAP XML being sent and received over the wire. These will be written to the current directory by default, but you can specify a path as an optional parameter to log_to_file:

client.xml_logger.log_to_file('/var/log/my_app')

The file will be named soap_xml.

Docs for Developers

$ rake rerdoc

to regenerate the project documentation if needed

$ rake build

to package the gem and create a release

$ rake test

to run unit tests on the library

$ rake -T

for a list of available tasks

Copyright/License Info

Copyright © 2009 all4miller. See MIT-LICENSE for details.