lupes Posted February 12, 2008 Share Posted February 12, 2008 hi, i am beginner and i would call a ireport with helpfrom webservice(jasperservice).How can i do this with Ruby on Rails, i now thereis a php help in the dir from Jasperserver but dontnow how i can do it with Ruby on Rails.Have anybody a idea??:( Link to comment Share on other sites More sharing options...
swood Posted February 13, 2008 Share Posted February 13, 2008 There is a long thread on this here: http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=&func=view&catid=10&id=15846#15846 You can use JasperServer web services (SOAP) to browse the repository and run reports. ShermanJasperSoft Link to comment Share on other sites More sharing options...
lupes Posted February 13, 2008 Author Share Posted February 13, 2008 hi and thank you for your helpi implement the follow example in my project:////////////////////////////////////require 'rexml/document'class ReportsController < ApplicationController include SendDoc def index@jasperServer ="http://10.16.22.230:8080/jasperserver/services/repository"@jasperUser = "jasperadmin"@jasperPass = "password"@jasperURI = '/reports'#'/reports/samples' @reportsXML = Reports.get_list(@jasperServer, @jasperUser, @jasperPass, @jasperURI) doc = REXML::Document.new(@reportsXML)@report_names = []@report_labels = []@res_type = []@parent_folder = [] doc.elements.each('operation-result/resource-descriptors/name') do |ele|@report_names << ele.textprint ele.textend doc.elements.each('operation-result/resource-descriptors/label') do |ele|@report_labels << ele.textend doc.elements.each('operation-result/resource-descriptors/resource-type') do |ele|@res_type << ele.textend doc.elements.each('operation-result/resource-descriptors/parent-folder') do |ele|@parent_folder << ele.textendend def run@jasperServer ="http://10.16.22.230:8080/jasperserver/services/repository"@jasperUser = "jasperadmin"@jasperPass = "password" @reportName = params[:reportURI].gsub(///, '_') @report = send_doc(@jasperServer, @jasperUser, @jasperPass, @reportName, params[:reportURI], params[:format])endend##### end app/controllers/reports_controller.rb module SendDocdef send_doc(strURL, strUser, strPass, strReportName, strReportURI, strOutputFmt) case strOutputFmtwhen 'PDF'mime_type = 'application/pdf'extension = 'pdf'else #rtfmime_type = 'application/rtf'extension = 'rtf'end send_data Reports.get_report(strURL, strUser, strPass, strReportURI, strOutputFmt),:filename => "#{strReportName}.#{extension}", :type => mime_type, :disposition => 'inline'endend##### end app/helpers/send_doc.rb ##### require 'soap/rpc/driver'class Reports < ActiveRecord::Base class << selfdef get_list(strURL, strUser, strPass, strURI) strRequestBody = %Q|<?xml version="1.0" encoding="UTF-8"?><request><operation-name>list</operation-name><resource-descriptor read-only="false" control-type="0"is-reference="false" is-new="false" strict-max="false"data-type="0" mandatory="false" has-data="false"strict-min="false" main-report="false" version="0"><uri-string>{strURI}</uri-string><ws-type>folder</ws-type></resource-descriptor></request>| driver = SOAP::RPC::Driver.new(strURL)driver.options["protocol.http.basic_auth"] << [strURL, strUser, strPass]driver.add_method('list','request') @report_list = driver.list(strRequestBody)end def get_report(strURL, strUser, strPass, strURI, strOutputFmt) strRequestBody = %Q|<?xml version="1.0" encoding="UTF-8"?><request><operation-name>runReport</operation-name><resource-descriptorread-only="false" control-type="0" is-reference="false"is-new="false" strict-max="false" data-type="0"mandatory="false" has-data="false" strict-min="false"main-report="false" version="0"><uri-string>#{strURI}</uri-string></resource-descriptor><arguments xmlnssi="http://www.w3.org/2001/XMLSchema-instance"xsi:type="java:com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.Argument"><name>RUN_OUTPUT_FORMAT</name><value>#{strOutputFmt}</value></arguments></request>| driver = SOAP::RPC::Driver.new(strURL)driver.options["protocol.http.basic_auth"] << [strURL, strUser, strPass]driver.add_method('runReport','request') report = driver.runReport(strRequestBody)["Include"].contentreportendend end/////////////////////////////// <% @page_title = 'Reports' %>Folder: <%= @parent_folder[0] %><br/><br/><% @report_names.each_with_index do |name, idx| %><% if @res_type[idx] == 'com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportUnit' %><li><%= @report_labels[idx] %><%= link_to(image_tag("/images/pdf.gif", :border => 0), :controller => "reports", :action => "run", :reportURI => "#{@jasperURI}/#{name}", :format => 'PDF')%><% end %><% end %> /////so far so good but i get no items in the list why:-( Link to comment Share on other sites More sharing options...
swood Posted February 14, 2008 Share Posted February 14, 2008 Sorry, I don't have the environment to play with this. You could try contacting the Ruby on Rails folks who got this working. Did you see any log messages indicating you were hitting JasperServer? ShermanJasperSoft Link to comment Share on other sites More sharing options...
lupes Posted February 19, 2008 Author Share Posted February 19, 2008 i try a simple test: i have a function def self.get_list()strUser = 'user'strPWD = 'password'strServer = 'http://localhost:8080/jasperserver/services/repository' strURI = %q{<?xml version="1.0" encoding="UTF-8"?><request><operation-name>list</operation-name><resource-descriptor read-only="false" control-type="0"is-reference="false" is-new="false" strict-max="false"data-type="0" mandatory="false" has-data="false"strict-min="false" main-report="false" version="0"><uri-string>/reports</uri-string><ws-type>folder</ws-type></resource-descriptor></request>} driver = SOAP::RPC::Driver.new(strServer)driver.wiredump_dev = STDERRdriver.options["protocol.http.basic_auth"] << [strServer, strUser, strPWD]driver.add_method('list','request') puts driver.list(strURI)//////////////////////////////////////and i call the function in the consoland i get the follow msg back://////////////////////////////////d=Reports.get_list()<?xml version="1.0" encoding="UTF-8"?><operationResult version="2.0.1"> <returnCode><![CDATA[0]]></returnCode></operationResult>=> nil why nil????Post edited by: lupes, at: 2008/02/19 10:17 Link to comment Share on other sites More sharing options...
swood Posted February 20, 2008 Share Posted February 20, 2008 can you connect to JasperServer with the iReport JasperServer plugin? It uses the same web services as you want from Ruby. Were there any errors in the JasperServer log? ShermanJasperSoft Link to comment Share on other sites More sharing options...
lupes Posted February 20, 2008 Author Share Posted February 20, 2008 Yes i can connecting from i-report with jasperserverplugin but when i call the function from ruby i getthe msg from Jasperserver log "ERROR ManagementService, http-8080-Processor 25:186-Encapsulation DIME? falsecan that be a risen why not works? Link to comment Share on other sites More sharing options...
swood Posted February 21, 2008 Share Posted February 21, 2008 If you can connect via the JasperServer plugin, then the JasperServer web services are working fine. You could turn on debugging for web services. Go into the WEB-INF/log4j.properties file and add a line log4j.logger.com.jaspersoft.jasperserver.ws.axis2=DEBUG You should be able to see what is going on. The ERROR is not an error - it is a mislabeled debug message. ShermanJasperSoft Link to comment Share on other sites More sharing options...
lupes Posted February 21, 2008 Author Share Posted February 21, 2008 hi i insert the line in the file and copy the las line from the logfile: 16:42:12,019 WARN LoggerListener,http-8080-Processor24:55 - Authentication event AuthenticationSuccessEvent: jasperadmin; details: org.acegisecurity.ui.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null16:42:12,019 ERROR ManagementService,http-8080-Processor24:186 - Encapsulation DIME? : false hope it help you :blush: Link to comment Share on other sites More sharing options...
yashdeep Posted November 16, 2009 Share Posted November 16, 2009 Hi lupes!!i tried some code solution from forum, it worked for me............ m getting list of sepecified folder location (URI)......... but when i run any report then i get this error on tomcat 10:21:06,718 DEBUG ManagementService,http-8085-Processor24:202 - Encapsulation DIME? : false10:21:06,734 DEBUG ManagementService,http-8085-Processor24:216 - Adding attachment: report, type: application/pdf10:21:06,750 DEBUG ManagementService,http-8085-Processor24:244 - Has descriptors: 010:21:06,765 DEBUG ManagementService,http-8085-Processor24:248 - marshalled response10:21:06,765 DEBUG ManagementService,http-8085-Processor24:249 - <?xml version="1.0" encoding="UTF-8"?><operationResult version="2.0.1"> <returnCode><![CDATA[0]]></returnCode></operationResult> i can see other information abt my report run....., like parameter values etc....... Thanks & Regards,Yash 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