mzukowski Posted April 9, 2008 Share Posted April 9, 2008 Variations of this have been posted here, however the old code had some bugs... this version works very well for us: http://pastebin.com/f4914d4db Here's a usage example (as a Rails controller action method): Code:def jasper_for_rails_example format = params[:format].downcase # e.g. 'PDF' mimetype = Mime::Type.lookup_by_extension(format) jasper = JasperClient.new(:username => 'foo', :«»password => 'bar') data = jasper.jasper.run_report('/foo/bar-report', format, 'start_date' => Time.parse(params['start_date']), 'end_date' => Time.parse(params['end_date']), 'some_other_param' => params['some_other_param'] ) send_data(data, :type => mimetype)end Link to comment Share on other sites More sharing options...
juantar Posted April 23, 2008 Share Posted April 23, 2008 Thank you so much for your code. Your code is cleaner than the one I have in my jasper_runner plugin. Do you mind if use it in my plugin? On the other hand, the sample client you posted has some typos. I believe it should be like this to work: Code:def jasper_for_rails_example format = params[:format] # e.g. 'PDF': format must remain uppercase for jasper to recognize it mimetype = Mime::Type.lookup_by_extension(format.downcase) jasper = JasperSoapClient.new(:username => 'foo', :«»password => 'bar') data = jasper.run_report('/foo/bar-report', format, 'start_date' => Time.parse(params['start_date']), 'end_date' => Time.parse(params['end_date']), 'some_other_param' => params['some_other_param'] ) send_data(data, :type => mimetype)end As a side note, I tested your code with a rails app running on Jruby and it works as long as I fix the httpclient.rb file (from the soap4r gem) to set SSLEnabled = false. Best regards,juantar Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now