= jasper_client
A client API for accessing jasper reports repository service.
The list, get, and runReport actions are supported.
JasperClient provides a mechanism to construct service requests
using Xml::Builder. Client methods (list, get, run_report) yield
to a block which is passed a builder to the guts of the SOAP
request. This allows for an easy mechanism to create XML that
is added to a request.
An example list request document:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:axis="http://axis2.ws.jasperserver.jaspersoft.com">
reportUnit
/Reports/xforty
]]>
When a call to list is made, a builder is passed to the block provided.
The above request could be executed using the list example below. In
a nuttshell, the caller needs to construct the body/ children of the
element. Short work can be made of this by
telling builder what to construct.
== Example list request
The list request retrieves information about a folders contents on the
jasper server. The jasper server organizes resources (reports, controls, queries
files, etc) in a folder hierarchy similar to the way modern computers manage
files.
A list request fetches the contents of a folder on the server.
A typical request might looks look like the following:
client = JasperClient::RepositoryService.new(wsdl, user, pass)
response = client.list do |request|
request.argument :name => "LIST_RESOURCES"
request.argument 'reportUnit', :name => "RESOURCE_TYPE"
request.argument '/Reports/xforty', :name => 'START_FROM_DIRECTORY'
end
response.success?
For more information see JasperClient::RepositoryService::Response::ListResponse.
response.each do |entry|
puts entry.name
end
== Example get request
A get request retrieves full information about a resource on the server. This example fetches
information about a report called user_list, though any resource type can be retuned with a
get.
response = client.get do |req|
req.resourceDescriptor :name => 'jrlogo', :wsType => 'report', :uriString => '/Reports/xforty/user_list', :isNew => 'false'
end
puts "Is successful: #{response.success?}"
For more information see JasperClient::RepositoryService::Response::GetResponse.
== Example runReport request
The runReport request produces report output in the desired format.
response = client.run_report do |req|
req.argument 'HTML', :name => 'RUN_OUTPUT_FORMAT'
req.resourceDescriptor :name => 'JRLogo',
:wsType => 'img',
:uriString => '/reports/xforty/user_list',
:isNew => 'false'
end
puts "Is successful: #{response.success?}"
puts "Parts? #{response.parts.count}"
response.parts.each do |part|
puts "Part: #{part.suggested_filename}"
end
For more information see JasperClient::RepositoryService::Response::RunReportResponse.
The class of the request depends on the type of request. It will be of
type ListResponse, GetResponse, or RunReportResponse.
Response types are specific to the request. Response types include
ListResponse, GetResponse, RunReportResponse, etc. Non-report
responses tend to be focused around the Resource class, which
represnets
xml response elements.
== Reports
Reports are unique. A report response is a multipart related mime
document. The parts include the XML SOAP response, the report content
(which might be a PDF, a CSV, or an HTML file with accompanying images
in their individual parts).
== Future
In the future helper methods for helping to hone in on various
kinds of info from the server will be built. For example, you might
want ot just find or list particular resource types like reports,
queries, etc.
Additionaly, the ability to update resources could be provided, but
we didn't have any use for this right now so we didn't focus on this.
== Copyright
Copyright (c) 2010 xforty technologies. See LICENSE for details.