Jump to content

ruby on rails again


lupes

Recommended Posts

hi,

 

i am beginner and i would call a ireport with help

from webservice(jasperservice).

How can i do this with Ruby on Rails, i now there

is a php help in the dir from Jasperserver but dont

now how i can do it with Ruby on Rails.

Have anybody a idea??

:(

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

hi

and thank you for your help

i 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.text

print ele.text

end

 

doc.elements.each('operation-result/resource-descriptors/label') do |ele|

@report_labels << ele.text

end

 

doc.elements.each('operation-result/resource-descriptors/resource-type') do |ele|

@res_type << ele.text

end

 

doc.elements.each('operation-result/resource-descriptors/parent-folder') do |ele|

@parent_folder << ele.text

end

end

 

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])

end

end

##### end app/controllers/reports_controller.rb

 

 

module SendDoc

def send_doc(strURL, strUser, strPass, strReportName, strReportURI, strOutputFmt)

 

case strOutputFmt

when 'PDF'

mime_type = 'application/pdf'

extension = 'pdf'

else #rtf

mime_type = 'application/rtf'

extension = 'rtf'

end

 

send_data Reports.get_report(strURL, strUser, strPass, strReportURI, strOutputFmt),

:filename => "#{strReportName}.#{extension}", :type => mime_type, :disposition => 'inline'

end

end

##### end app/helpers/send_doc.rb #####

 

 

require 'soap/rpc/driver'

class Reports < ActiveRecord::Base

 

class << self

def 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-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></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"].content

report

end

end

 

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

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 = STDERR

driver.options["protocol.http.basic_auth"] << [strServer, strUser, strPWD]

driver.add_method('list','request')

 

puts driver.list(strURI)

//////////////////////////////////////

and i call the function in the consol

and 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

Yes i can connecting from i-report with jasperserverplugin but when i call the function from ruby i get

the msg from Jasperserver log "ERROR ManagementService, http-8080-Processor 25:186-Encapsulation DIME? false

can that be a risen why not works?

Link to comment
Share on other sites

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.

 

 

Sherman

JasperSoft

Link to comment
Share on other sites

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: null

16:42:12,019 ERROR ManagementService,http-8080-Processor24:186 - Encapsulation DIME? : false

 

hope it help you :blush:

Link to comment
Share on other sites

  • 1 year later...

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 D
IME? : false
10:21:06,734 DEBUG ManagementService,http-8085-Processor24:216 - Adding attachme
nt: report, type: application/pdf
10:21:06,750 DEBUG ManagementService,http-8085-Processor24:244 - Has descriptors
: 0
10:21:06,765 DEBUG ManagementService,http-8085-Processor24:248 - marshalled resp
onse
10: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

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...