Jump to content
We've recently updated our Privacy Statement, available here ×

integrate jasperintelligence with ruby on rails


paulc

Recommended Posts

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

Hello MariusAgricola,

Really Thank you very much for this great work.

I am looking in google for long how to integrate jasper in ruby.

From your work i able to get idea for how to integrate japser in ruby.

 

Here i need your help.

 

I have tried to integrate japser in ruby using your code.

But i got the error.

Following is more information:

-- In ruby application i list the reports that resides on jaspserserver repository.

-- I have installed JasperIntelligence1.0.1.

-- Error Details:

 

REXML:: ParseException in ReportController#index

 

Missing end tag for 'HR' (got "body")

Line:

Position:

Last 80 unconsumed characters:

</html>

 

Full trace:

 

/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:315:in `pull'

/usr/lib/ruby/1.8/rexml/parsers/streamparser.rb:16:in `parse'

/usr/lib/ruby/1.8/rexml/document.rb:185:in `parse_stream'

/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/xsd/xmlparser/rexmlparser.rb:27:in `do_parse'

/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/parser.rb:102:in `parse'

/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/processor.rb:39:in `unmarshal'

/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/rpc/proxy.rb:285:in `unmarshal'

/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/rpc/proxy.rb:184:in `route'

/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/rpc/proxy.rb:143:in `call'

/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/rpc/driver.rb:181:in `call'

(eval):6:in `list'

app/models/reports.rb:21:in `get_list'

app/controllers/report_controller.rb:22:in `index'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `send'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `perform_action_without_filters'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in `call_filter'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in `perform_action_without_benchmark'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'

/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in `perform_action'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `send'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `process_without_filters'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in `process_without_session_management_support'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in `process'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in `process'

/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in `dispatch'

/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:113:in `handle_dispatch'

/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:79:in `service'

/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'

/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'

/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'

/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'

/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'

/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'

/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'

/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'

/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'

/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'

/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:63:in `dispatch'

/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/webrick.rb:59

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'

/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require'

/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in `new_constants_in'

/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require'

/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'

script/server:3

 

Please can you tell me what is reason for this kind of error.

Am i missing anything in installing Jasperintelligence?

What you have installed to use jasper in ruby?

(I mean i wanna to know that which jasperintelligence version u have used?)

What i have to do to solve this problem?

 

Please help me in solving my this problem.

 

Thank you

Link to comment
Share on other sites

it looks like whatever it is you're parsing is not a SOAP response from JasperServer but HTML... are you sure you're fetching data from the right URL? And are you sure JasperServer is returning data correctly at that URL (maybe it's replying with a generic "500 Server Error" HTML page at the URL you're querying?)
Link to comment
Share on other sites

  • 3 weeks later...

MariusAgricola, thank you very much for your hard work. The problem I'm running into is defining dynamic queries using the service. For example, if I want to use JasperServer to print shopping carts -- the query would be '... WHERE user=$P{current_user}' -- but how do I pass that information into the service call?

 

I would love to pull data from the database, format in XML, and pass XML directly to JasperServer in service call -- can I include XML directly in SOAP message?

 

thanks,

john

Link to comment
Share on other sites

jgladden:

 

That's essentially the problem I never was able to solve. I had no problem running a report that had no parameters, but I never did figure out how to construct the XML request in such a way that it included parameters that made any sense.

 

What I would suggest, since I haven't had time to work on it myself, is to fire up a packet sniffer (WireShark, aka Ethereal, works well for this) and use Jasper Reports with the iReport plugin to connect to your Jasper Server. Develop a report that takes parameters and upload it to the server. Then you can use the iReport plugin to browse to the repository and run the report. Do this while running your packet sniffer and you should be able to pick up the relevant packets. Look for the particular XML that contains something like <parameter...> blocks.

 

The last time I tried this, which was almost a year ago, I was able to see the parameter fields, but I am almost always working with dates. Unfortunately, I couldn't figure out what format the dates were in (they were integers that may have represented something like Unix Epoch time, but I'm not certain).

 

Anyway, as I keep meaning to return to this, hopefully I can figure something out. Unfortunately, my setup is far outdated with the latest JI release. I'd be ecstatic if someone manages to figure this out and incorporate it into something that others can get at (such as rolling it into a plugin or gem).

Link to comment
Share on other sites

The Web Services guide shipped with JasperServer describes how to include parameters values in a runReport web service request. Basically parameter values are sent via <paramater> elements inside the resource descriptor:

Code:

<resourceDescriptor>
..
<parameter name="Parameter1Name">Parameter1Value</parameter>
<parameter name="Parameter2Name">Parameter2Value</parameter>
<parameter name="MultiParameterName" isListItem="true">MultiParameterValue1</parameter>
<parameter name="MultiParameterName" isListItem="true">MultiParameterValue2</parameter>
</resourceDescriptor>

 

Dates need to be sent as the number of milliseconds since the Unix epoch (Jan 1st 1970 00:00:00 GMT).

 

If anyone intends to implements this, we can offer further assistance on how the JasperServer web service works.

 

Regards,

Lucian

Link to comment
Share on other sites

Has anyone been able to use this code with a Jruby rails application? I tried it but I got a "basic authentication not implemented in soapr + http" so I installed the httpclient gem. Now the error is that the x509 store constant is missing (I think it is related to jopenssl).

 

On the other hand you may find this code useful for sending parameters in the request (note that it uses the code from the previous posts):

 

Code:
 
#Takes a hash that has as keys the name of the jasper report parameter and as
# a value, the value you want for that parameter. The name of the parameter must be
# exactly the same as you have it defined in your jasper report.
def create_xml_params(param_values_hash)
xml_params = ""
param_values_hash.each do |key, value|
xml_params << "n<parameter name="#{key.to_s}">#{value.to_s}</parameter>"
end
return xml_params
end

def get_report(strURL, strUser, strPass, strURI, strOutputFmt, params_xml = ""«»)

strRequestBody = %Q|<request operationName="runReport" locale="en">
<argument name="RUN_OUTPUT_FORMAT">#{strOutputFmt}</argument>
<resourceDescriptor name="" wsType="" uriString="#{strURI}" isNew="false">
<label>null</label>
#{params_xml}
</resourceDescriptor>
</request>
|

driver = SOAP::RPC::«»Driver.new(strURL)
#driver.wiredump_dev=STDERR
driver.options["protocol.http.basic_auth"] << [strURL, strUser, strPass]
driver.add_method('runReport','request')
#driver.add_method('runReport','request')
result, env = driver.runReport(strRequestBody.to_s)
report = env.external_content['report'].data.content

report




end

 

Example:

 

Code:
[code]
k5_params = {}
k5_params[:quarter] = "1"
k5_params[:«»student_id] = 329

report_name = '/reports/k5_progress_rpt'
report_pdf_file = Reports.get_report(@jasperServer, @jasperUser, @jasperPass,
report_name, 'PDF',
Reports.create_xml_params(k5_params))
Link to comment
Share on other sites

  • 10 months later...
  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...