gunark-jasperserver-client 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +26 -0
- data/PostInstall.txt +7 -0
- data/README +0 -0
- data/README.txt +48 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +15 -0
- data/init.rb +5 -0
- data/lib/jasper_server/client.rb +50 -0
- data/lib/jasper_server/error.rb +4 -0
- data/lib/jasper_server/protocols/basic.rb +97 -0
- data/lib/jasper_server/protocols/soap.rb +70 -0
- data/lib/jasper_server/protocols/soap_monkeypatch.rb +54 -0
- data/lib/jasper_server/report_request.rb +37 -0
- data/lib/jasper_server/version.rb +9 -0
- data/lib/jasperserver-client.rb +1 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +2 -0
- data/test/test_jasperserver-client.rb +11 -0
- metadata +102 -0
data/History.txt
ADDED
data/License.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2008 FIXME full name
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
History.txt
|
|
2
|
+
License.txt
|
|
3
|
+
Manifest.txt
|
|
4
|
+
PostInstall.txt
|
|
5
|
+
README
|
|
6
|
+
README.txt
|
|
7
|
+
Rakefile
|
|
8
|
+
config/hoe.rb
|
|
9
|
+
config/requirements.rb
|
|
10
|
+
lib/jasperserver-client.rb
|
|
11
|
+
lib/jasperserver-client/version.rb
|
|
12
|
+
script/console
|
|
13
|
+
script/destroy
|
|
14
|
+
script/generate
|
|
15
|
+
script/txt2html
|
|
16
|
+
setup.rb
|
|
17
|
+
tasks/deployment.rake
|
|
18
|
+
tasks/environment.rake
|
|
19
|
+
tasks/website.rake
|
|
20
|
+
test/test_helper.rb
|
|
21
|
+
test/test_jasperserver-client.rb
|
|
22
|
+
website/index.html
|
|
23
|
+
website/index.txt
|
|
24
|
+
website/javascripts/rounded_corners_lite.inc.js
|
|
25
|
+
website/stylesheets/screen.css
|
|
26
|
+
website/template.html.erb
|
data/PostInstall.txt
ADDED
data/README
ADDED
|
File without changes
|
data/README.txt
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
= jasperserver-client
|
|
2
|
+
|
|
3
|
+
* FIX (url)
|
|
4
|
+
|
|
5
|
+
== DESCRIPTION:
|
|
6
|
+
|
|
7
|
+
FIX (describe your package)
|
|
8
|
+
|
|
9
|
+
== FEATURES/PROBLEMS:
|
|
10
|
+
|
|
11
|
+
* FIX (list of features or problems)
|
|
12
|
+
|
|
13
|
+
== SYNOPSIS:
|
|
14
|
+
|
|
15
|
+
FIX (code sample of usage)
|
|
16
|
+
|
|
17
|
+
== REQUIREMENTS:
|
|
18
|
+
|
|
19
|
+
* FIX (list of requirements)
|
|
20
|
+
|
|
21
|
+
== INSTALL:
|
|
22
|
+
|
|
23
|
+
* FIX (sudo gem install, anything else)
|
|
24
|
+
|
|
25
|
+
== LICENSE:
|
|
26
|
+
|
|
27
|
+
(The MIT License)
|
|
28
|
+
|
|
29
|
+
Copyright (c) 2008 FIXME full name
|
|
30
|
+
|
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
32
|
+
a copy of this software and associated documentation files (the
|
|
33
|
+
'Software'), to deal in the Software without restriction, including
|
|
34
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
35
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
36
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
37
|
+
the following conditions:
|
|
38
|
+
|
|
39
|
+
The above copyright notice and this permission notice shall be
|
|
40
|
+
included in all copies or substantial portions of the Software.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
43
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
44
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
45
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
46
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
47
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
48
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/config/hoe.rb
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'jasper_server/version'
|
|
2
|
+
|
|
3
|
+
AUTHOR = 'Matt Zukowski' # can also be an array of Authors
|
|
4
|
+
EMAIL = "matt@zukowski.ca"
|
|
5
|
+
DESCRIPTION = "Ruby-based client for JasperServer. Allows for requesting and fetching reports using Ruby from a networked JasperServer over SOAP."
|
|
6
|
+
GEM_NAME = 'jasperserver-client' # what ppl will type to install your gem
|
|
7
|
+
RUBYFORGE_PROJECT = 'jasper-client' # The unix name for your project
|
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
|
10
|
+
|
|
11
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
|
12
|
+
@config = nil
|
|
13
|
+
RUBYFORGE_USERNAME = "gunark"
|
|
14
|
+
def rubyforge_username
|
|
15
|
+
unless @config
|
|
16
|
+
begin
|
|
17
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
|
18
|
+
rescue
|
|
19
|
+
puts <<-EOS
|
|
20
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
|
21
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
|
22
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
|
23
|
+
EOS
|
|
24
|
+
exit
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
REV = nil
|
|
32
|
+
# UNCOMMENT IF REQUIRED:
|
|
33
|
+
# REV = YAML.load(`svn info`)['Revision']
|
|
34
|
+
VERS = JasperServer::VERSION::STRING + (REV ? ".#{REV}" : "")
|
|
35
|
+
RDOC_OPTS = ['--quiet', '--title', 'jasperserver-client documentation',
|
|
36
|
+
"--opname", "index.html",
|
|
37
|
+
"--line-numbers",
|
|
38
|
+
"--main", "README",
|
|
39
|
+
"--inline-source"]
|
|
40
|
+
|
|
41
|
+
class Hoe
|
|
42
|
+
def extra_deps
|
|
43
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
|
44
|
+
@extra_deps
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Generate all the Rake tasks
|
|
49
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
|
50
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
51
|
+
p.developer(AUTHOR, EMAIL)
|
|
52
|
+
p.description = DESCRIPTION
|
|
53
|
+
p.summary = DESCRIPTION
|
|
54
|
+
p.url = HOMEPATH
|
|
55
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
|
56
|
+
p.test_globs = ["test/**/test_*.rb"]
|
|
57
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
|
58
|
+
|
|
59
|
+
# == Optional
|
|
60
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
|
61
|
+
#p.extra_deps = EXTRA_DEPENDENCIES
|
|
62
|
+
|
|
63
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
|
67
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
|
68
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
|
69
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
|
70
|
+
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
include FileUtils
|
|
3
|
+
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
|
6
|
+
begin
|
|
7
|
+
require req_gem
|
|
8
|
+
rescue LoadError
|
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
|
11
|
+
exit
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
data/init.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'jasper_server/protocols/soap'
|
|
2
|
+
|
|
3
|
+
module JasperServer
|
|
4
|
+
class Client
|
|
5
|
+
|
|
6
|
+
# Create a new instance of the client.
|
|
7
|
+
#
|
|
8
|
+
# url :: The URL of the JasperServer. This should look something like:
|
|
9
|
+
# "http://<hostname>:<port>/jasperserver/services/repository"
|
|
10
|
+
# username :: The username used to connect to the JasperServer.
|
|
11
|
+
# password :: The password used to connect to the JasperServer.
|
|
12
|
+
def initialize(url, username, password)
|
|
13
|
+
unless url =~ /\/services\/repository\/?$/
|
|
14
|
+
# add the /services/repository suffix to the URL if the user forgot
|
|
15
|
+
# to include it
|
|
16
|
+
url << "/services/repository"
|
|
17
|
+
|
|
18
|
+
puts "WARNING: You may have forgotten to add the '/services/repository' "+
|
|
19
|
+
"to your JasperServer URL. Your URL has been automatically changed to #{url.inspect}."
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
@jasper_url = url
|
|
23
|
+
@jasper_username = username
|
|
24
|
+
@jasper_password = password
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Request a report from the server based on the given ReportRequest.
|
|
28
|
+
# Returns the report data.
|
|
29
|
+
#
|
|
30
|
+
# For example if your request specifies 'PDF' as the output format, PDF
|
|
31
|
+
# binary data will be returned.
|
|
32
|
+
#
|
|
33
|
+
# client = JasperServer::Client.new("http://example.com/jasperserver/services/repository",
|
|
34
|
+
# "jasperadmin", "secret!")
|
|
35
|
+
# request = JasperServer::Request.new("/example/my-report", "PDF", {'fruit' => 'apple'})
|
|
36
|
+
# pdf_data = client.request_report(request)
|
|
37
|
+
# File.open('/tmp/report.pdf', 'w') do |f|
|
|
38
|
+
# f.puts(pdf_data)
|
|
39
|
+
# end
|
|
40
|
+
#
|
|
41
|
+
# For debugging purposes, try requesting output in 'CSV' format, since
|
|
42
|
+
# request_report will then return an easily readable String.
|
|
43
|
+
def request_report(request)
|
|
44
|
+
soap = JasperServer::Protocols::SOAP.new
|
|
45
|
+
soap.connect(@jasper_url, @jasper_username, @jasper_password)
|
|
46
|
+
soap.request_report_via_soap(request)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
require 'jasper_server/error'
|
|
2
|
+
|
|
3
|
+
module JasperServer
|
|
4
|
+
module Protocols
|
|
5
|
+
|
|
6
|
+
# THIS DOES NOT WORK!!!
|
|
7
|
+
#
|
|
8
|
+
# This was an attempt at fetching reports using scraping... unfortunately
|
|
9
|
+
# I can't figure out how to fake the Spring authentication session :(
|
|
10
|
+
class Basic
|
|
11
|
+
# EXAMPLE URL FOR FETCHING REPORT
|
|
12
|
+
# http://jas01:8080/jasperserver/flow.html?_flowId=viewReportFlow&reportUnit=/u-track/project-totals-for-orgunit&standAlone=true&ParentFolderUri=/u-track&orgunit-id=2&start-date=20080801040000&end-date=20080831040000&output=swf&decorate=no
|
|
13
|
+
|
|
14
|
+
def request_report_via_url(request)
|
|
15
|
+
report_unit = request.report_unit
|
|
16
|
+
output_format = request.output_format
|
|
17
|
+
report_params = request.report_params
|
|
18
|
+
|
|
19
|
+
params = {}
|
|
20
|
+
report_params.each do |name, value|
|
|
21
|
+
if value.kind_of? Time
|
|
22
|
+
params[name] = ReportRequest.convert_time_to_jasper_timestamp(value)
|
|
23
|
+
else
|
|
24
|
+
params[name] = value
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
params['_flowId'] = 'viewReportFlow'
|
|
29
|
+
params['standAlone'] = 'true'
|
|
30
|
+
#params['parentFolderUri'] = '/u-track'
|
|
31
|
+
params['decorate'] = 'no'
|
|
32
|
+
|
|
33
|
+
params['reportUnit'] = report_unit
|
|
34
|
+
params['output'] = output_format
|
|
35
|
+
|
|
36
|
+
puts "FETCHING LOGIN PAGE"
|
|
37
|
+
uri = URI.parse("http://jas01:8080/jasperserver/login.html")
|
|
38
|
+
res = Net::HTTP.start(uri.host, uri.port) do |http|
|
|
39
|
+
http.get(uri.path)
|
|
40
|
+
end
|
|
41
|
+
res['set-cookie'] =~ /JSESSIONID=([a-z0-9]*);/i
|
|
42
|
+
jsessionid = $~[1]
|
|
43
|
+
puts "SESSION ID IS #{jsessionid}"
|
|
44
|
+
|
|
45
|
+
sleep 1
|
|
46
|
+
|
|
47
|
+
uri = URI.parse("http://jas01:8080/jasperserver/j_acegi_security_check")
|
|
48
|
+
|
|
49
|
+
# FIXME: logging in doesn't work :(
|
|
50
|
+
|
|
51
|
+
puts "LOGGING IN"
|
|
52
|
+
req = Net::HTTP::Post.new(uri.path)
|
|
53
|
+
req.set_form_data({'j_username' => 'jasperadmin', 'j_password' => 'jasper!', 'btnsubmit' => 'Login', 'jsessionid' => jsessionid})
|
|
54
|
+
|
|
55
|
+
client = Net::HTTP.new(uri.host, uri.port)
|
|
56
|
+
result = client.start do |http|
|
|
57
|
+
puts "LOGIN REQ"
|
|
58
|
+
puts req.to_hash.inspect
|
|
59
|
+
http.request(req)
|
|
60
|
+
end
|
|
61
|
+
#res = Net::HTTP.post_form(uri, {'j_username' => 'jasperadmin', 'j_password' => 'jasper!', 'btnsubmit' => 'Login'})
|
|
62
|
+
puts "LOGIN RESP HEADERS"
|
|
63
|
+
puts res.to_hash.inspect
|
|
64
|
+
puts res.inspect
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
uri = URI.parse("http://jas01:8080/jasperserver/flow.html")
|
|
69
|
+
#
|
|
70
|
+
#req = Net::HTTP::Post.new(uri.path)
|
|
71
|
+
#req.set_form_data(params, '&')
|
|
72
|
+
|
|
73
|
+
sleep 1
|
|
74
|
+
|
|
75
|
+
# FIXME: this should fetch the report, but instead we get redirected to the login page
|
|
76
|
+
# since I can't seem to get the fake login to work :(
|
|
77
|
+
|
|
78
|
+
params['jsessionid'] =
|
|
79
|
+
q = params.collect{|k,v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join("&")
|
|
80
|
+
uri.query = q
|
|
81
|
+
req = Net::HTTP::Get.new(uri.request_uri)
|
|
82
|
+
puts uri.request_uri
|
|
83
|
+
|
|
84
|
+
client = Net::HTTP.new(uri.host, uri.port)
|
|
85
|
+
result = client.start do |http|
|
|
86
|
+
puts req.to_hash.inspect
|
|
87
|
+
http.request(req)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
return result
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
class Error < JasperServer::Error
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'jasper_server/protocols/soap_monkeypatch'
|
|
2
|
+
require 'jasper_server/error'
|
|
3
|
+
|
|
4
|
+
module JasperServer
|
|
5
|
+
module Protocols
|
|
6
|
+
class SOAP
|
|
7
|
+
JASPER_URN = "urn:"
|
|
8
|
+
|
|
9
|
+
def request_report_via_soap(request)
|
|
10
|
+
raise Error, "Must connect to JasperServer first!" if @driver.nil?
|
|
11
|
+
|
|
12
|
+
report = request.report_unit
|
|
13
|
+
format = request.output_format
|
|
14
|
+
params = request.report_params
|
|
15
|
+
|
|
16
|
+
params_xml = ""
|
|
17
|
+
params.each do |name, value|
|
|
18
|
+
if value.kind_of? Array
|
|
19
|
+
value.each do |item|
|
|
20
|
+
params_xml << %{<parameter name="#{name}" isListItem="true">#{@@html_encoder.encode(item, :decimal)}</parameter>\n}
|
|
21
|
+
end
|
|
22
|
+
elsif value.kind_of? Time
|
|
23
|
+
ts = ReportRequest.convert_time_to_jasper_timestamp(value)
|
|
24
|
+
params_xml << %{<parameter name="#{name}">#{ts}</parameter>\n}
|
|
25
|
+
elsif value.kind_of? Integer
|
|
26
|
+
params_xml << %{<parameter name="#{name}">#{value}</parameter>\n}
|
|
27
|
+
elsif !value.blank?
|
|
28
|
+
params_xml << %{<parameter name="#{name}"><![CDATA[#{value}]]></parameter>\n}
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
request = %Q|<request operationName="runReport" locale="en">
|
|
33
|
+
<argument name="RUN_OUTPUT_FORMAT">#{format}</argument>
|
|
34
|
+
<resourceDescriptor name="" wsType=""
|
|
35
|
+
uriString="#{report}"
|
|
36
|
+
isNew="false">
|
|
37
|
+
<label>null</label>
|
|
38
|
+
#{params_xml}
|
|
39
|
+
</resourceDescriptor>
|
|
40
|
+
</request>|
|
|
41
|
+
|
|
42
|
+
RAILS_DEFAULT_LOGGER.debug "JasperSoapClient Request:\n#{request}"
|
|
43
|
+
|
|
44
|
+
result = @driver.runReport(request)
|
|
45
|
+
|
|
46
|
+
RAILS_DEFAULT_LOGGER.debug "JasperSoapClient Response:\n#{result}"
|
|
47
|
+
|
|
48
|
+
xml = XmlSimple.xml_in_string(result)
|
|
49
|
+
unless xml['returnCode'].first.to_i == 0
|
|
50
|
+
raise JasperServer::Error, "JasperServer replied with an error: #{xml['returnMessage'] ? xml['returnMessage'].first : xml.inspect}"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
result.instance_variable_get(:@env).external_content['report'].data.content
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def connect(url, username, password)
|
|
57
|
+
@driver = connect_to_soap_service(url, username, password)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
protected
|
|
61
|
+
def connect_to_soap_service(url, username, password)
|
|
62
|
+
driver = ::SOAP::RPC::Driver.new(url, JASPER_URN)
|
|
63
|
+
driver.options['protocol.http.basic_auth'] << [url, username, password]
|
|
64
|
+
|
|
65
|
+
driver.add_method('runReport', 'requestXmlString')
|
|
66
|
+
return driver
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require 'soap/rpc/driver'
|
|
2
|
+
|
|
3
|
+
# Modify SOAP::RPC::Proxy class to return SOAP Message in addition to object mapping
|
|
4
|
+
# to access the SOAP attachments
|
|
5
|
+
# Taken from: http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=&func=view&catid=10&id=31754#31754
|
|
6
|
+
module SOAP
|
|
7
|
+
module RPC
|
|
8
|
+
|
|
9
|
+
class Proxy
|
|
10
|
+
include SOAP
|
|
11
|
+
|
|
12
|
+
def call(name, *params)
|
|
13
|
+
unless op_info = @operation[name]
|
|
14
|
+
raise MethodDefinitionError, "method: #{name} not defined"
|
|
15
|
+
end
|
|
16
|
+
mapping_opt = create_mapping_opt
|
|
17
|
+
req_header = create_request_header
|
|
18
|
+
req_body = SOAPBody.new(
|
|
19
|
+
op_info.request_body(params, @mapping_registry,
|
|
20
|
+
@literal_mapping_registry, mapping_opt)
|
|
21
|
+
)
|
|
22
|
+
reqopt = create_encoding_opt(
|
|
23
|
+
:soapaction => op_info.soapaction || @soapaction,
|
|
24
|
+
:envelopenamespace => @options["soap.envelope.requestnamespace"],
|
|
25
|
+
:default_encodingstyle =>
|
|
26
|
+
@default_encodingstyle || op_info.request_default_encodingstyle,
|
|
27
|
+
:elementformdefault => op_info.elementformdefault,
|
|
28
|
+
:attributeformdefault => op_info.attributeformdefault
|
|
29
|
+
)
|
|
30
|
+
resopt = create_encoding_opt(
|
|
31
|
+
:envelopenamespace => @options["soap.envelope.responsenamespace"],
|
|
32
|
+
:default_encodingstyle =>
|
|
33
|
+
@default_encodingstyle || op_info.response_default_encodingstyle,
|
|
34
|
+
:elementformdefault => op_info.elementformdefault,
|
|
35
|
+
:attributeformdefault => op_info.attributeformdefault
|
|
36
|
+
)
|
|
37
|
+
env = route(req_header, req_body, reqopt, resopt)
|
|
38
|
+
raise EmptyResponseError unless env
|
|
39
|
+
receive_headers(env.header)
|
|
40
|
+
begin
|
|
41
|
+
check_fault(env.body)
|
|
42
|
+
rescue ::SOAP::FaultError => e
|
|
43
|
+
op_info.raise_fault(e, @mapping_registry, @literal_mapping_registry)
|
|
44
|
+
end
|
|
45
|
+
response_obj = op_info.response_obj(env.body, @mapping_registry,
|
|
46
|
+
@literal_mapping_registry, mapping_opt)
|
|
47
|
+
response_obj.instance_variable_set(:@env, env)
|
|
48
|
+
return response_obj
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|