Giter Club home page Giter Club logo

jasper-client's Introduction

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">
  <soapenv:Body>
    <axis:list soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <requestXmlString xsi:type="xsd:string">
      <![CDATA[
         <request operationName="list"> 
           <argument name="LIST_RESOURCES"/> 
           <argument name="RESOURCE_TYPE">reportUnit</argument> 
           <argument name="START_FROM_DIRECTORY">/Reports/xforty</argument> 
        </request>
        ]]>
      </requestXmlString>
     </axis:list>
  </soapenv:Body>
</soapenv:Envelope>

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 <request></request> 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 <resourceDescriptor> 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 © 2010 xforty technologies. See LICENSE for details.

jasper-client's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.