keeguon-actionwebservice 3.0.1 → 3.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/Rakefile +25 -25
- data/lib/action_web_service/api.rb +4 -2
- data/lib/action_web_service/casting.rb +5 -1
- data/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +4 -28
- data/lib/action_web_service/protocol/abstract.rb +1 -1
- data/lib/action_web_service/protocol/soap_protocol.rb +15 -12
- data/lib/action_web_service/scaffolding.rb +16 -16
- data/lib/action_web_service/templates/scaffolds/methods.html.erb +2 -2
- data/lib/action_web_service/templates/scaffolds/parameters.html.erb +1 -1
- data/lib/action_web_service/templates/scaffolds/result.html.erb +1 -1
- data/lib/action_web_service/version.rb +3 -3
- data/lib/action_web_service.rb +10 -6
- metadata +8 -8
data/README
CHANGED
data/Rakefile
CHANGED
@@ -9,15 +9,15 @@ require 'fileutils'
|
|
9
9
|
require File.join(File.dirname(__FILE__), 'lib', 'action_web_service', 'version')
|
10
10
|
|
11
11
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ".#{Time.now.strftime('%Y%m%d%H%M%S')}"
|
12
|
-
PKG_NAME = '
|
12
|
+
PKG_NAME = 'dps-actionwebservice'
|
13
13
|
PKG_VERSION = ActionWebService::VERSION::STRING + PKG_BUILD
|
14
14
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
15
15
|
PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
|
16
16
|
|
17
17
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
18
18
|
|
19
|
-
RUBY_FORGE_PROJECT = "
|
20
|
-
RUBY_FORGE_USER = "
|
19
|
+
RUBY_FORGE_PROJECT = ""
|
20
|
+
RUBY_FORGE_USER = ""
|
21
21
|
|
22
22
|
desc "Default Task"
|
23
23
|
task :default => [ :test ]
|
@@ -104,18 +104,18 @@ Rake::GemPackageTask.new(spec) do |p|
|
|
104
104
|
end
|
105
105
|
|
106
106
|
|
107
|
-
|
108
|
-
desc "Publish the API documentation"
|
109
|
-
task :pgem => [:package] do
|
110
|
-
Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
111
|
-
`ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
desc "Publish the API documentation"
|
116
|
-
task :pdoc => [:rdoc] do
|
117
|
-
Rake::SshDirPublisher.new("davidhh@wrath.rubyonrails.org", "public_html/aws", "doc").upload
|
118
|
-
end
|
107
|
+
## Publish beta gem
|
108
|
+
#desc "Publish the API documentation"
|
109
|
+
#task :pgem => [:package] do
|
110
|
+
# Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
111
|
+
# `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
|
112
|
+
#end
|
113
|
+
#
|
114
|
+
## Publish documentation
|
115
|
+
#desc "Publish the API documentation"
|
116
|
+
#task :pdoc => [:rdoc] do
|
117
|
+
# Rake::SshDirPublisher.new("davidhh@wrath.rubyonrails.org", "public_html/aws", "doc").upload
|
118
|
+
#end
|
119
119
|
|
120
120
|
|
121
121
|
def each_source_file(*args)
|
@@ -172,13 +172,13 @@ task :lines do
|
|
172
172
|
puts " Lines #{total_lines}, LOC #{total_loc}"
|
173
173
|
end
|
174
174
|
|
175
|
-
desc "Publish the release files to RubyForge."
|
176
|
-
task :release => [ :package ] do
|
177
|
-
require 'rubyforge'
|
178
|
-
|
179
|
-
packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
|
180
|
-
|
181
|
-
rubyforge = RubyForge.new
|
182
|
-
rubyforge.login
|
183
|
-
rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
|
184
|
-
end
|
175
|
+
#desc "Publish the release files to RubyForge."
|
176
|
+
#task :release => [ :package ] do
|
177
|
+
# require 'rubyforge'
|
178
|
+
#
|
179
|
+
# packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
|
180
|
+
#
|
181
|
+
# rubyforge = RubyForge.new
|
182
|
+
# rubyforge.login
|
183
|
+
# rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
|
184
|
+
#end
|
@@ -82,8 +82,10 @@ module ActionWebService # :nodoc:
|
|
82
82
|
if expects
|
83
83
|
expects.each do |type|
|
84
84
|
type = type.element_type if type.is_a?(ArrayType)
|
85
|
-
if
|
86
|
-
|
85
|
+
if Object.const_defined?('ActiveRecord')
|
86
|
+
if type.type_class.ancestors.include?(ActiveRecord::Base) && !allow_active_record_expects
|
87
|
+
raise(ActionWebServiceError, "ActiveRecord model classes not allowed in :expects")
|
88
|
+
end
|
87
89
|
end
|
88
90
|
end
|
89
91
|
end
|
@@ -31,7 +31,11 @@ module ActionWebService # :nodoc:
|
|
31
31
|
|
32
32
|
def cast_expects(api_method, params) # :nodoc:
|
33
33
|
return [] if api_method.expects.nil?
|
34
|
-
|
34
|
+
if params.is_a?(Array)
|
35
|
+
api_method.expects.zip(params).map{ |type, param| cast(param, type) }
|
36
|
+
elsif params.is_a?(Hash)
|
37
|
+
api_method.expects.map {|type| cast(params[type.name.to_s], type) }
|
38
|
+
end
|
35
39
|
end
|
36
40
|
|
37
41
|
def cast_returns(api_method, return_value) # :nodoc:
|
@@ -137,27 +137,6 @@ module ActionWebService # :nodoc:
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
def log_error(exception)
|
141
|
-
return unless logger
|
142
|
-
|
143
|
-
ActiveSupport::Deprecation.silence do
|
144
|
-
if ActionView::TemplateError === exception
|
145
|
-
logger.fatal(exception.to_s)
|
146
|
-
else
|
147
|
-
logger.fatal(
|
148
|
-
"\n#{exception.class} (#{exception.message}):\n " +
|
149
|
-
clean_backtrace(exception).join("\n ") + "\n\n"
|
150
|
-
)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def clean_backtrace(exception)
|
156
|
-
defined?(Rails) && Rails.respond_to?(:backtrace_cleaner) ?
|
157
|
-
Rails.backtrace_cleaner.clean(exception.backtrace) :
|
158
|
-
exception.backtrace
|
159
|
-
end
|
160
|
-
|
161
140
|
def indent(body)
|
162
141
|
body.split(/\n/).map{|x| " #{x}"}.join("\n")
|
163
142
|
end
|
@@ -171,15 +150,14 @@ module ActionWebService # :nodoc:
|
|
171
150
|
SoapHttpTransport = 'http://schemas.xmlsoap.org/soap/http'
|
172
151
|
|
173
152
|
def wsdl
|
174
|
-
|
175
|
-
when :get
|
153
|
+
if request.get?
|
176
154
|
begin
|
177
155
|
options = { :type => 'text/xml', :disposition => 'inline' }
|
178
156
|
send_data(to_wsdl, options)
|
179
157
|
rescue Exception => e
|
180
158
|
log_error(e) unless logger.nil?
|
181
159
|
end
|
182
|
-
|
160
|
+
elsif request.post?
|
183
161
|
render :status => 500, :text => 'POST not supported'
|
184
162
|
end
|
185
163
|
end
|
@@ -187,8 +165,7 @@ module ActionWebService # :nodoc:
|
|
187
165
|
private
|
188
166
|
def base_uri
|
189
167
|
host = request.host_with_port
|
190
|
-
|
191
|
-
relative_url_root = '' #::ActionController::Base.relative_url_root
|
168
|
+
relative_url_root = Rails.configuration.action_controller[:relative_url_root]
|
192
169
|
scheme = request.ssl? ? 'https' : 'http'
|
193
170
|
'%s://%s%s/%s/' % [scheme, host, relative_url_root, self.class.controller_path]
|
194
171
|
end
|
@@ -206,8 +183,7 @@ module ActionWebService # :nodoc:
|
|
206
183
|
case dispatching_mode
|
207
184
|
when :direct
|
208
185
|
api = self.class.web_service_api
|
209
|
-
web_service_name =
|
210
|
-
api = (web_service_name + '_api').classify.constantize unless api
|
186
|
+
web_service_name = controller_name.sub(/Controller$/, '').underscore
|
211
187
|
apis[web_service_name] = [api, register_api(api, marshaler)]
|
212
188
|
when :delegated, :layered
|
213
189
|
self.class.web_services.each do |web_service_name, info|
|
@@ -3,6 +3,11 @@ require 'action_web_service/protocol/soap_protocol/marshaler'
|
|
3
3
|
require 'soap/streamHandler'
|
4
4
|
require 'action_web_service/client/soap_client'
|
5
5
|
|
6
|
+
SOAP::SOAPNamespaceTag = 'env'
|
7
|
+
SOAP::XSDNamespaceTag = 'xsd'
|
8
|
+
SOAP::XSINamespaceTag = 'xsi'
|
9
|
+
|
10
|
+
|
6
11
|
module ActionWebService # :nodoc:
|
7
12
|
module API # :nodoc:
|
8
13
|
class Base # :nodoc:
|
@@ -59,7 +64,9 @@ module ActionWebService # :nodoc:
|
|
59
64
|
end
|
60
65
|
request = envelope.body.request
|
61
66
|
method_name = request.elename.name
|
62
|
-
params =
|
67
|
+
params = {}
|
68
|
+
request.each {|k,v| params[k] = marshaler.soap_to_ruby(v) }
|
69
|
+
|
63
70
|
Request.new(self, method_name, params, service_name, nil, nil, protocol_options)
|
64
71
|
end
|
65
72
|
|
@@ -102,16 +109,12 @@ module ActionWebService # :nodoc:
|
|
102
109
|
response = SOAP::RPC::SOAPMethodResponse.new(qname, nil)
|
103
110
|
else
|
104
111
|
if return_value.is_a?(Exception)
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
SOAP::SOAPString.new(return_value.to_s),
|
112
|
-
SOAP::SOAPString.new(self.class.name),
|
113
|
-
marshaler.ruby_to_soap(detail))
|
114
|
-
end
|
112
|
+
detail = SOAP::Mapping::SOAPException.new(return_value)
|
113
|
+
response = SOAP::SOAPFault.new(
|
114
|
+
SOAP::SOAPQName.new('%s:%s' % [SOAP::SOAPNamespaceTag, 'Server']),
|
115
|
+
SOAP::SOAPString.new(return_value.to_s),
|
116
|
+
SOAP::SOAPString.new(self.class.name),
|
117
|
+
marshaler.ruby_to_soap(detail))
|
115
118
|
else
|
116
119
|
if return_type
|
117
120
|
param_def = [['retval', 'return', marshaler.lookup_type(return_type).mapping]]
|
@@ -150,7 +153,7 @@ module ActionWebService # :nodoc:
|
|
150
153
|
|
151
154
|
private
|
152
155
|
def has_valid_soap_action?(request)
|
153
|
-
return nil unless request.
|
156
|
+
return nil unless request.post?
|
154
157
|
soap_action = request.env['HTTP_SOAPACTION']
|
155
158
|
return nil unless soap_action
|
156
159
|
soap_action = soap_action.dup
|
@@ -42,21 +42,21 @@ module ActionWebService
|
|
42
42
|
add_template_helper(Helpers)
|
43
43
|
module_eval <<-"end_eval", __FILE__, __LINE__ + 1
|
44
44
|
def #{action_name}
|
45
|
-
if request.
|
45
|
+
if request.get?
|
46
46
|
setup_invocation_assigns
|
47
47
|
render_invocation_scaffold 'methods'
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
def #{action_name}_method_params
|
52
|
-
if request.
|
52
|
+
if request.get?
|
53
53
|
setup_invocation_assigns
|
54
54
|
render_invocation_scaffold 'parameters'
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
def #{action_name}_submit
|
59
|
-
if request.
|
59
|
+
if request.post?
|
60
60
|
setup_invocation_assigns
|
61
61
|
protocol_name = params['protocol'] ? params['protocol'].to_sym : :soap
|
62
62
|
case protocol_name
|
@@ -108,16 +108,16 @@ module ActionWebService
|
|
108
108
|
customized_template = "\#{self.class.controller_path}/#{action_name}/\#{action}"
|
109
109
|
default_template = scaffold_path(action)
|
110
110
|
begin
|
111
|
-
content =
|
111
|
+
content = view_context.render(:file => customized_template)
|
112
112
|
rescue ActionView::MissingTemplate
|
113
|
-
content =
|
113
|
+
content = view_context.render(:file => default_template)
|
114
114
|
end
|
115
|
-
@
|
116
|
-
if self.
|
115
|
+
@content_for_layout = content
|
116
|
+
#if self.action_has_layout?
|
117
|
+
# render :file => self.send(:_layout), :use_full_path => true
|
118
|
+
#else
|
117
119
|
render :file => scaffold_path("layout")
|
118
|
-
|
119
|
-
render :file => self.active_layout, :use_full_path => true
|
120
|
-
end
|
120
|
+
#end
|
121
121
|
end
|
122
122
|
|
123
123
|
def scaffold_path(template_name)
|
@@ -125,8 +125,8 @@ module ActionWebService
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def reset_invocation_response
|
128
|
-
|
129
|
-
response.instance_variable_set :@header, Rack::Utils::HeaderHash.new(
|
128
|
+
self.instance_variable_set(:@_response_body, nil)
|
129
|
+
response.instance_variable_set :@header, Rack::Utils::HeaderHash.new("cookie" => [], 'Content-Type' => 'text/html')
|
130
130
|
end
|
131
131
|
|
132
132
|
def public_method_name(service_name, method_name)
|
@@ -179,12 +179,12 @@ module ActionWebService
|
|
179
179
|
true)
|
180
180
|
if member_type.custom?
|
181
181
|
parameters << content_tag('li', label)
|
182
|
-
parameters << content_tag('ul', nested_content)
|
182
|
+
parameters << content_tag('ul', nested_content.html_safe)
|
183
183
|
else
|
184
|
-
parameters << content_tag('li', label + ' ' + nested_content)
|
184
|
+
parameters << content_tag('li', (label + ' ' + nested_content).html_safe)
|
185
185
|
end
|
186
186
|
end
|
187
|
-
content_tag('ul', parameters)
|
187
|
+
content_tag('ul', parameters.html_safe)
|
188
188
|
else
|
189
189
|
# If the data source was structured previously we already have the index set
|
190
190
|
field_name_base = "#{field_name_base}[#{idx}]" unless was_structured
|
@@ -228,7 +228,7 @@ module ActionWebService
|
|
228
228
|
methods = service.api_methods_full.sort {|a, b| a[1] <=> b[1]}.map do |desc, name|
|
229
229
|
content_tag("li", link_to(name, :action => action, :service => service.name, :method => name))
|
230
230
|
end
|
231
|
-
content_tag("ul", methods.join("\n"))
|
231
|
+
content_tag("ul", methods.join("\n").html_safe)
|
232
232
|
end
|
233
233
|
end
|
234
234
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h4>Method Invocation Details for <em><%= @scaffold_service %>#<%= @scaffold_method.public_name %></em></h4>
|
2
2
|
|
3
|
-
|
3
|
+
<%= form_tag(:action => @scaffold_action_name + '_submit') do -%>
|
4
4
|
<%= hidden_field_tag "service", @scaffold_service.name %>
|
5
5
|
<%= hidden_field_tag "method", @scaffold_method.public_name %>
|
6
6
|
|
@@ -26,5 +26,5 @@ Invocation took <tt><%= '%f' % @method_elapsed %></tt> seconds
|
|
26
26
|
</p>
|
27
27
|
|
28
28
|
<p>
|
29
|
-
<%= link_to "Back",
|
29
|
+
<%= link_to "Back", "#{@scaffold_action_name}_method_params?method=#{@scaffold_method.public_name}&service=#{@scaffold_service.name}" %>
|
30
30
|
</p>
|
data/lib/action_web_service.rb
CHANGED
@@ -22,15 +22,19 @@
|
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
23
|
#++
|
24
24
|
|
25
|
+
|
25
26
|
begin
|
26
|
-
require '
|
27
|
-
require '
|
28
|
-
require '
|
27
|
+
require 'activesupport'
|
28
|
+
require 'actioncontroller'
|
29
|
+
require 'activerecord'
|
30
|
+
require 'actionpack'
|
31
|
+
require 'active_support/core_ext/class/inheritable_attributes'
|
32
|
+
require 'action_dispatch/routing'
|
29
33
|
rescue LoadError
|
30
34
|
require 'rubygems'
|
31
|
-
gem 'activesupport'
|
32
|
-
gem 'actionpack'
|
33
|
-
gem 'activerecord'
|
35
|
+
gem 'activesupport', '>=3.0.5'
|
36
|
+
gem 'actionpack' , '>=3.0.5'
|
37
|
+
gem 'activerecord' , '>=3.0.5'
|
34
38
|
end
|
35
39
|
|
36
40
|
$:.unshift(File.dirname(__FILE__) + "/action_web_service/vendor/")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keeguon-actionwebservice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire: actionwebservice
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 3.0.
|
21
|
+
version: 3.0.17
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 3.0.
|
29
|
+
version: 3.0.17
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: actionpack
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 3.0.
|
37
|
+
version: 3.0.17
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 3.0.
|
45
|
+
version: 3.0.17
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: activerecord
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 3.0.
|
53
|
+
version: 3.0.17
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.0.
|
61
|
+
version: 3.0.17
|
62
62
|
description: Adds WSDL/SOAP and XML-RPC web service support to Action Pack
|
63
63
|
email: rubyjedi@gmail.com, bitserf@gmail.com, ksibilev@yahoo.com
|
64
64
|
executables: []
|