keeguon-actionwebservice 3.1.1 → 3.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f32ed2010ad383912faba630b0b490c6fb1c340
4
- data.tar.gz: b4cc523f99b1dd3f56a6f8d40aa28a4d449e4dd5
3
+ metadata.gz: 61d6e96218d9ff3f1a0b1346fa481a583ba2324a
4
+ data.tar.gz: f8b72ce64ac3b4daba29c084b4f84aa19604d2b7
5
5
  SHA512:
6
- metadata.gz: 078de0a728373f4c40a2370cec186b519ea6040c06f64d44e0286c960597df7546e5e98e7cacbdebfb15b1c55978e404a5fbd91a98a0cb4237d8ac0951b44fa3
7
- data.tar.gz: 85c0e82477c686b11e695d3b04d5cd1fbd051b89237f95b2320a7cbd8e30546a447787674518fd4156674b9017e56efe34b5db829f0ce97c95374c0e17f41148
6
+ metadata.gz: 7c2722574fff39bbced78313de244d1f0a3da84d74de1c9e08f8011c0f94f06080b8556bc549fd2c3da14890fe80ee2e470a362f7cb6bac55d7e8bb5c9ad3149
7
+ data.tar.gz: 33edac77e9d4179375e4c91c97678a6e20e85e39951bdbb37ff2fc964edb532d01fc1ea3f9d9683e5ac03b5f00fe05e4b771c79cb89572af9c1a463ea50862ac
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
  require 'rake/testtask'
4
- require 'rake/rdoctask'
4
+ require 'rdoc/task'
5
5
  require 'rake/packagetask'
6
- require 'rake/gempackagetask'
6
+ require 'rubygems/package_task'
7
7
  require 'rake/contrib/rubyforgepublisher'
8
8
  require 'fileutils'
9
9
  require File.join(File.dirname(__FILE__), 'lib', 'action_web_service', 'version')
@@ -97,7 +97,7 @@ spec = Gem::Specification.new do |s|
97
97
  s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) }
98
98
  s.files = s.files + Dir.glob( "generators/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) }
99
99
  end
100
- Rake::GemPackageTask.new(spec) do |p|
100
+ Gem::PackageTask.new(spec) do |p|
101
101
  p.gem_spec = spec
102
102
  p.need_tar = true
103
103
  p.need_zip = true
@@ -23,19 +23,12 @@
23
23
  #++
24
24
 
25
25
 
26
- begin
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'
33
- rescue LoadError
34
- require 'rubygems'
35
- gem 'activesupport', '>=3.0.5'
36
- gem 'actionpack' , '>=3.0.5'
37
- gem 'activerecord' , '>=3.0.5'
38
- end
26
+ require 'active_support'
27
+ require 'action_controller'
28
+ require 'active_record'
29
+ require 'action_pack'
30
+ require 'active_support/core_ext/class'
31
+ require 'action_dispatch/routing'
39
32
 
40
33
  $:.unshift(File.dirname(__FILE__) + "/action_web_service/vendor/")
41
34
 
@@ -35,9 +35,11 @@ module ActionWebService # :nodoc:
35
35
  # Disallow instantiation
36
36
  private_class_method :new, :allocate
37
37
 
38
+ class_attribute :api_methods_attr, :api_public_method_names_attr, :default_api_method_instance_attr
39
+ self.api_methods_attr = self.api_public_method_names_attr = {}
40
+
38
41
  class << self
39
42
  include ActionWebService::SignatureTypes
40
-
41
43
  # API methods have a +name+, which must be the Ruby method name to use when
42
44
  # performing the invocation on the web service object.
43
45
  #
@@ -92,8 +94,8 @@ module ActionWebService # :nodoc:
92
94
  name = name.to_sym
93
95
  public_name = public_api_method_name(name)
94
96
  method = Method.new(name, public_name, expects, returns)
95
- write_inheritable_hash("api_methods", name => method)
96
- write_inheritable_hash("api_public_method_names", public_name => name)
97
+ self.api_methods_attr = self.api_methods_attr.merge({ name => method })
98
+ self.api_public_method_names_attr = self.api_public_method_names_attr.merge({ public_name => name })
97
99
  end
98
100
 
99
101
  # Whether the given method name is a service method on this API
@@ -105,7 +107,7 @@ module ActionWebService # :nodoc:
105
107
  # ProjectsApi.has_api_method?('GetCount') #=> false
106
108
  # ProjectsApi.has_api_method?(:getCount) #=> true
107
109
  def has_api_method?(name)
108
- api_methods.has_key?(name)
110
+ self.api_methods_attr.has_key?(name)
109
111
  end
110
112
 
111
113
  # Whether the given public method name has a corresponding service method
@@ -118,7 +120,7 @@ module ActionWebService # :nodoc:
118
120
  # ProjectsApi.has_api_method?(:getCount) #=> false
119
121
  # ProjectsApi.has_api_method?('GetCount') #=> true
120
122
  def has_public_api_method?(public_name)
121
- api_public_method_names.has_key?(public_name)
123
+ self.api_public_method_names_attr.has_key?(public_name)
122
124
  end
123
125
 
124
126
  # The corresponding public method name for the given service method name
@@ -141,7 +143,7 @@ module ActionWebService # :nodoc:
141
143
  #
142
144
  # ProjectsApi.api_method_name('GetCount') #=> :getCount
143
145
  def api_method_name(public_name)
144
- api_public_method_names[public_name]
146
+ self.api_public_method_names_attr[public_name]
145
147
  end
146
148
 
147
149
  # A Hash containing all service methods on this API, and their
@@ -157,7 +159,7 @@ module ActionWebService # :nodoc:
157
159
  # :getCompletedCount=>#<ActionWebService::API::Method:0x2437794 ...>}
158
160
  # ProjectsApi.api_methods[:getCount].public_name #=> "GetCount"
159
161
  def api_methods
160
- read_inheritable_attribute("api_methods") || {}
162
+ self.api_methods_attr
161
163
  end
162
164
 
163
165
  # The Method instance for the given public API method name, if any
@@ -189,18 +191,18 @@ module ActionWebService # :nodoc:
189
191
  # The Method instance for the default API method, if any
190
192
  def default_api_method_instance
191
193
  return nil unless name = default_api_method
192
- instance = read_inheritable_attribute("default_api_method_instance")
194
+ instance = self.default_api_method_instance_attr
193
195
  if instance && instance.name == name
194
196
  return instance
195
197
  end
196
198
  instance = Method.new(name, public_api_method_name(name), nil, nil)
197
- write_inheritable_attribute("default_api_method_instance", instance)
199
+ self.default_api_method_instance_attr = instance
198
200
  instance
199
201
  end
200
202
 
201
203
  private
202
204
  def api_public_method_names
203
- read_inheritable_attribute("api_public_method_names") || {}
205
+ self.api_public_method_names_attr || {}
204
206
  end
205
207
 
206
208
  def validate_options(valid_option_keys, supplied_option_keys)
@@ -8,6 +8,9 @@ module ActionWebService # :nodoc:
8
8
  def self.included(base) # :nodoc:
9
9
  base.extend(ClassMethods)
10
10
  base.send(:include, ActionWebService::Container::Delegated::InstanceMethods)
11
+ base.class_attribute :web_services, :web_service_definition_callbacks
12
+ base.web_services = {}
13
+ base.web_service_definition_callbacks = []
11
14
  end
12
15
 
13
16
  module ClassMethods
@@ -47,7 +50,7 @@ module ActionWebService # :nodoc:
47
50
  else
48
51
  info = { name => { :object => object } }
49
52
  end
50
- write_inheritable_hash("web_services", info)
53
+ self.web_services = self.web_services.merge(info)
51
54
  call_web_service_definition_callbacks(self, name, info)
52
55
  end
53
56
 
@@ -56,17 +59,13 @@ module ActionWebService # :nodoc:
56
59
  web_services.has_key?(name.to_sym)
57
60
  end
58
61
 
59
- def web_services # :nodoc:
60
- read_inheritable_attribute("web_services") || {}
61
- end
62
-
63
62
  def add_web_service_definition_callback(&block) # :nodoc:
64
- write_inheritable_array("web_service_definition_callbacks", [block])
63
+ self.web_service_definition_callbacks = self.web_service_definition_callbacks + [block]
65
64
  end
66
65
 
67
66
  private
68
67
  def call_web_service_definition_callbacks(container_class, web_service_name, service_info)
69
- (read_inheritable_attribute("web_service_definition_callbacks") || []).each do |block|
68
+ self.web_service_definition_callbacks.each do |block|
70
69
  block.call(container_class, web_service_name, service_info)
71
70
  end
72
71
  end
@@ -7,6 +7,8 @@ module ActionWebService # :nodoc:
7
7
 
8
8
  def self.included(base) # :nodoc:
9
9
  base.extend(ClassMethods)
10
+ base.class_attribute :web_service_api_callbacks, :web_service_api_attr
11
+ base.web_service_api_callbacks = []
10
12
  end
11
13
 
12
14
  module ClassMethods
@@ -41,7 +43,7 @@ module ActionWebService # :nodoc:
41
43
  # end
42
44
  def web_service_api(definition=nil)
43
45
  if definition.nil?
44
- read_inheritable_attribute("web_service_api")
46
+ self.web_service_api_attr
45
47
  else
46
48
  if definition.is_a?(Symbol)
47
49
  raise(ContainerError, "symbols can only be used for #web_service_api inside of a controller")
@@ -49,18 +51,18 @@ module ActionWebService # :nodoc:
49
51
  unless definition.respond_to?(:ancestors) && definition.ancestors.include?(ActionWebService::API::Base)
50
52
  raise(ContainerError, "#{definition.to_s} is not a valid API definition")
51
53
  end
52
- write_inheritable_attribute("web_service_api", definition)
54
+ self.web_service_api_attr = definition
53
55
  call_web_service_api_callbacks(self, definition)
54
56
  end
55
57
  end
56
58
 
57
59
  def add_web_service_api_callback(&block) # :nodoc:
58
- write_inheritable_array("web_service_api_callbacks", [block])
60
+ self.web_service_api_callbacks = self.web_service_api_callbacks + [block]
59
61
  end
60
62
 
61
63
  private
62
64
  def call_web_service_api_callbacks(container_class, definition)
63
- (read_inheritable_attribute("web_service_api_callbacks") || []).each do |block|
65
+ self.web_service_api_callbacks.each do |block|
64
66
  block.call(container_class, definition)
65
67
  end
66
68
  end
@@ -63,18 +63,18 @@ module ActionWebService # :nodoc:
63
63
  end
64
64
  log_request(ws_request, request.raw_post)
65
65
  if exception
66
- Rails.logger.debug(exception) unless Rails.logger.nil?
66
+ Rails.logger.error(exception) unless logger.nil?
67
67
  send_web_service_error_response(ws_request, exception)
68
68
  else
69
69
  send_web_service_response(ws_response, bm.real)
70
70
  end
71
71
  else
72
72
  exception ||= DispatcherError.new("Malformed SOAP or XML-RPC protocol message")
73
- Rails.logger.debug(exception) unless Rails.logger.nil?
73
+ Rails.logger.error(exception) unless logger.nil?
74
74
  send_web_service_error_response(ws_request, exception)
75
75
  end
76
76
  rescue Exception => e
77
- Rails.logger.debug(e) unless Rails.logger.nil?
77
+ Rails.logger.error(e) unless logger.nil?
78
78
  send_web_service_error_response(ws_request, e)
79
79
  end
80
80
 
@@ -114,7 +114,7 @@ module ActionWebService # :nodoc:
114
114
  end
115
115
 
116
116
  def log_request(ws_request, body)
117
- unless Rails.logger.nil?
117
+ unless logger.nil?
118
118
  name = ws_request.method_name
119
119
  api_method = ws_request.api_method
120
120
  params = ws_request.method_params
@@ -124,16 +124,16 @@ module ActionWebService # :nodoc:
124
124
  params = params.map{ |param| param.inspect }
125
125
  end
126
126
  service = ws_request.service_name
127
- Rails.logger.debug("\nWeb Service Request: #{name}(#{params.join(", ")}) Entrypoint: #{service}")
128
- Rails.logger.debug(indent(body))
127
+ logger.debug("\nWeb Service Request: #{name}(#{params.join(", ")}) Entrypoint: #{service}")
128
+ logger.debug(indent(body))
129
129
  end
130
130
  end
131
131
 
132
132
  def log_response(ws_response, elapsed=nil)
133
- unless Rails.logger.nil?
133
+ unless logger.nil?
134
134
  elapsed = (elapsed ? " (%f):" % elapsed : ":")
135
- Rails.logger.debug("\nWeb Service Response" + elapsed + " => #{ws_response.return_value.inspect}")
136
- Rails.logger.debug(indent(ws_response.body))
135
+ logger.debug("\nWeb Service Response" + elapsed + " => #{ws_response.return_value.inspect}")
136
+ logger.debug(indent(ws_response.body))
137
137
  end
138
138
  end
139
139
 
@@ -155,8 +155,7 @@ module ActionWebService # :nodoc:
155
155
  options = { :type => 'text/xml', :disposition => 'inline' }
156
156
  send_data(to_wsdl, options)
157
157
  rescue Exception => e
158
- Rails.logger.debug(e) unless Rails.logger.nil?
159
- throw e
158
+ Rails.logger.error(e) unless logger.nil?
160
159
  end
161
160
  elsif request.post?
162
161
  render :status => 500, :text => 'POST not supported'
@@ -166,7 +165,7 @@ module ActionWebService # :nodoc:
166
165
  private
167
166
  def base_uri
168
167
  host = request.host_with_port
169
- relative_url_root = Rails.configuration.action_controller[:relative_url_root]
168
+ relative_url_root = self.config.relative_url_root
170
169
  scheme = request.ssl? ? 'https' : 'http'
171
170
  '%s://%s%s/%s/' % [scheme, host, relative_url_root, self.class.controller_path]
172
171
  end
@@ -184,7 +183,7 @@ module ActionWebService # :nodoc:
184
183
  case dispatching_mode
185
184
  when :direct
186
185
  api = self.class.web_service_api
187
- web_service_name = controller_name.sub(/Controller$/, '').underscore
186
+ web_service_name = self.class.name.sub(/Controller$/, '').underscore
188
187
  apis[web_service_name] = [api, register_api(api, marshaler)]
189
188
  when :delegated, :layered
190
189
  self.class.web_services.each do |web_service_name, info|
@@ -7,6 +7,10 @@ module ActionWebService # :nodoc:
7
7
  def self.included(base) # :nodoc:
8
8
  base.extend(ClassMethods)
9
9
  base.send(:include, ActionWebService::Invocation::InstanceMethods)
10
+ base.class_attribute :included_intercepted_methods, :excluded_intercepted_methods
11
+ base.included_intercepted_methods = base.excluded_intercepted_methods = {}
12
+ base.class_attribute :before_invocation_interceptors_attr, :after_invocation_interceptors_attr
13
+ base.before_invocation_interceptors_attr = after_invocation_interceptors_attr = []
10
14
  end
11
15
 
12
16
  # Invocation interceptors provide a means to execute custom code before
@@ -82,29 +86,24 @@ module ActionWebService # :nodoc:
82
86
  alias :after_invocation :append_after_invocation
83
87
 
84
88
  def before_invocation_interceptors # :nodoc:
85
- read_inheritable_attribute("before_invocation_interceptors")
89
+ self.before_invocation_interceptors_attr
86
90
  end
87
91
 
88
92
  def after_invocation_interceptors # :nodoc:
89
- read_inheritable_attribute("after_invocation_interceptors")
90
- end
91
-
92
- def included_intercepted_methods # :nodoc:
93
- read_inheritable_attribute("included_intercepted_methods") || {}
94
- end
95
-
96
- def excluded_intercepted_methods # :nodoc:
97
- read_inheritable_attribute("excluded_intercepted_methods") || {}
93
+ self.after_invocation_interceptors_attr
98
94
  end
99
95
 
100
96
  private
101
97
  def append_interceptors_to_chain(condition, interceptors)
102
- write_inheritable_array("#{condition}_invocation_interceptors", interceptors)
98
+ meth = "#{condition}_invocation_interceptors_attr"
99
+ self.send("#{meth}=", self.send(meth) + interceptors)
103
100
  end
104
101
 
105
102
  def prepend_interceptors_to_chain(condition, interceptors)
106
- interceptors = interceptors + read_inheritable_attribute("#{condition}_invocation_interceptors")
107
- write_inheritable_attribute("#{condition}_invocation_interceptors", interceptors)
103
+ meth = "#{condition}_invocation_interceptors_attr"
104
+ interceptors = interceptors + self.send(meth)
105
+
106
+ self.send("#{meth}=", self.send(meth) + interceptors)
108
107
  end
109
108
 
110
109
  def extract_conditions!(interceptors)
@@ -115,8 +114,8 @@ module ActionWebService # :nodoc:
115
114
  def add_interception_conditions(interceptors, conditions)
116
115
  return unless conditions
117
116
  included, excluded = conditions[:only], conditions[:except]
118
- write_inheritable_hash("included_intercepted_methods", condition_hash(interceptors, included)) && return if included
119
- write_inheritable_hash("excluded_intercepted_methods", condition_hash(interceptors, excluded)) if excluded
117
+ self.included_intercepted_methods = self.included_intercepted_methods.merge(condition_hash(interceptors, included)) && return if included
118
+ self.excluded_intercepted_methods = self.excluded_intercepted_methods.merge(condition_hash(interceptors, excluded)) if excluded
120
119
  end
121
120
 
122
121
  def condition_hash(interceptors, *methods)
@@ -5,18 +5,20 @@ module ActionWebService # :nodoc:
5
5
  def self.included(base)
6
6
  base.extend(ClassMethods)
7
7
  base.send(:include, ActionWebService::Protocol::Discovery::InstanceMethods)
8
+ base.class_attribute :web_service_protocols
9
+ base.web_service_protocols = []
8
10
  end
9
11
 
10
12
  module ClassMethods # :nodoc:
11
13
  def register_protocol(klass)
12
- write_inheritable_array("web_service_protocols", [klass])
14
+ self.web_service_protocols = self.web_service_protocols + [klass]
13
15
  end
14
16
  end
15
17
 
16
18
  module InstanceMethods # :nodoc:
17
19
  private
18
20
  def discover_web_service_request(action_pack_request)
19
- (self.class.read_inheritable_attribute("web_service_protocols") || []).each do |protocol|
21
+ self.class.web_service_protocols.each do |protocol|
20
22
  protocol = protocol.create(self)
21
23
  request = protocol.decode_action_pack_request(action_pack_request)
22
24
  return request unless request.nil?
@@ -25,7 +27,7 @@ module ActionWebService # :nodoc:
25
27
  end
26
28
 
27
29
  def create_web_service_client(api, protocol_name, endpoint_uri, options)
28
- (self.class.read_inheritable_attribute("web_service_protocols") || []).each do |protocol|
30
+ self.class.web_service_protocols.each do |protocol|
29
31
  protocol = protocol.create(self)
30
32
  client = protocol.protocol_client(api, protocol_name, endpoint_uri, options)
31
33
  return client unless client.nil?
@@ -155,10 +155,23 @@ module ActionWebService # :nodoc:
155
155
  soap_action.gsub!(/^"/, '')
156
156
  soap_action.gsub!(/"$/, '')
157
157
  soap_action.strip!
158
+ soap_action = get_action_from_envelope(request.env["RAW_POST_DATA"]) if soap_action.empty?
158
159
  return nil if soap_action.empty?
159
160
  soap_action
160
161
  end
161
162
 
163
+ # Allow for consumers that do not send the method name in the
164
+ # HTTP_SOAPACTION http header. In this mode the method name is in the
165
+ # XML tag under Envelope/Body in the Soap request. Without this
166
+ # change, Rails is unable to determine the method name unless it's
167
+ # provided in HTTP_SOAPACTION.
168
+ # TODO: Find out which clients do this and comment them here.
169
+ def get_action_from_envelope(data)
170
+ require 'nokogiri'
171
+ node = Nokogiri.XML(data).xpath("/*[local-name()='Envelope']/*[local-name()='Body']/*[1]").first
172
+ (node.nil? || node.name.nil?) ? "" : node.name.strip
173
+ end
174
+
162
175
  def create_soap_envelope(body)
163
176
  header = SOAP::SOAPHeader.new
164
177
  body = SOAP::SOAPBody.new(body)
@@ -25,26 +25,27 @@ module ActionWebService
25
25
  @value = value
26
26
  end
27
27
 
28
+ class_attribute :simple_restrictions, :xml_base
29
+ self.simple_restrictions = {}
30
+ self.xml_base = ""
31
+
28
32
  class << self
29
33
  def base(type)
30
34
  type = type.to_s.camelize(:lower)
31
- write_inheritable_attribute("xml_base", type)
32
- class_eval <<-END
33
- def xml_base; "#{type}"; end
34
- END
35
+ self.xml_base = type
35
36
  end
36
37
 
37
38
  def restriction_base
38
- read_inheritable_attribute("xml_base") || ""
39
+ self.xml_base
39
40
  end
40
41
 
41
42
  def restriction(type, value)
42
43
  type = type.to_s.camelize(:lower)
43
- write_inheritable_hash("simple_restrictions", type => value)
44
+ self.simple_restrictions = self.simple_restrictions.merge({ type => value })
44
45
  end
45
46
 
46
47
  def restrictions
47
- read_inheritable_attribute("simple_restrictions") || {}
48
+ self.simple_restrictions
48
49
  end
49
50
 
50
51
  end
@@ -42,6 +42,9 @@ module ActionWebService
42
42
  end
43
43
  end
44
44
 
45
+ class_attribute :struct_members
46
+ self.struct_members = {}
47
+
45
48
  class << self
46
49
  # Creates a structure member with the specified +name+ and +type+. Additional wsdl
47
50
  # schema properties may be specified in the optional hash +options+. Generates
@@ -49,7 +52,7 @@ module ActionWebService
49
52
  def member(name, type, options={})
50
53
  name = name.to_sym
51
54
  type = ActionWebService::SignatureTypes.canonical_signature_entry({ name => type }, 0)
52
- write_inheritable_hash("struct_members", name => [type, options])
55
+ self.struct_members = self.struct_members.merge({ name => [type, options] })
53
56
  class_eval <<-END
54
57
  def #{name}; @#{name}; end
55
58
  def #{name}=(value); @#{name} = value; end
@@ -57,7 +60,7 @@ module ActionWebService
57
60
  end
58
61
 
59
62
  def members # :nodoc:
60
- read_inheritable_attribute("struct_members") || {}
63
+ self.struct_members
61
64
  end
62
65
 
63
66
  def member_type(name) # :nodoc:
@@ -1,27 +1,27 @@
1
1
  # encoding: UTF-8
2
2
  class Class # :nodoc:
3
3
  def class_inheritable_option(sym, default_value=nil)
4
- class_attribute sym
5
-
4
+ class_attribute "#{sym}_attr"
5
+ self.send("#{sym}_attr=", default_value) if default_value
6
6
  class_eval <<-EOS
7
7
  def self.#{sym}(value=nil)
8
- class_attribute :#{sym}
9
8
  if !value.nil?
10
- self.#{sym} = value
9
+ self.#{sym}_attr = value
10
+ else
11
+ self.#{sym}_attr
11
12
  end
12
13
  end
13
14
 
14
15
  def self.#{sym}=(value)
15
- class_attribute :#{sym}
16
- self.#{sym} = value
16
+ self.#{sym}_attr = value
17
17
  end
18
18
 
19
19
  def #{sym}
20
- self.class.#{sym}
20
+ self.class.#{sym}_attr
21
21
  end
22
22
 
23
23
  def #{sym}=(value)
24
- self.class.#{sym} = value
24
+ self.class.#{sym}_attr = value
25
25
  end
26
26
  EOS
27
27
  end
@@ -1,111 +1,107 @@
1
1
  # encoding: UTF-8
2
- require 'test/unit'
3
2
 
4
- module Test # :nodoc:
5
- module Unit # :nodoc:
6
- class TestCase # :nodoc:
7
- private
8
- # invoke the specified API method
9
- def invoke_direct(method_name, *args)
10
- prepare_request('api', 'api', method_name, *args)
11
- @controller.process(@request, @response)
12
- decode_rpc_response
13
- end
14
- alias_method :invoke, :invoke_direct
3
+ module ActionWebServiceInvokeHelper
4
+ private
5
+ # invoke the specified API method
6
+ def invoke_direct(method_name, *args)
7
+ prepare_request('api', 'api', method_name, *args)
8
+ @controller.dispatch('api', @request, @response)
9
+ decode_rpc_response
10
+ end
11
+ alias_method :invoke, :invoke_direct
15
12
 
16
- # invoke the specified API method on the specified service
17
- def invoke_delegated(service_name, method_name, *args)
18
- prepare_request(service_name.to_s, service_name, method_name, *args)
19
- @controller.process(@request, @response)
20
- decode_rpc_response
21
- end
13
+ # invoke the specified API method on the specified service
14
+ def invoke_delegated(service_name, method_name, *args)
15
+ prepare_request(service_name.to_s, service_name, method_name, *args)
16
+ @controller.dispatch('api', @request, @response)
17
+ decode_rpc_response
18
+ end
22
19
 
23
- # invoke the specified layered API method on the correct service
24
- def invoke_layered(service_name, method_name, *args)
25
- prepare_request('api', service_name, method_name, *args)
26
- @controller.process(@request, @response)
27
- decode_rpc_response
28
- end
20
+ # invoke the specified layered API method on the correct service
21
+ def invoke_layered(service_name, method_name, *args)
22
+ prepare_request('api', service_name, method_name, *args)
23
+ @controller.dispatch('api', @request, @response)
24
+ decode_rpc_response
25
+ end
29
26
 
30
- # ---------------------- internal ---------------------------
27
+ # ---------------------- internal ---------------------------
31
28
 
32
- def prepare_request(action, service_name, api_method_name, *args)
33
- @request.recycle!
34
- @request.request_parameters['action'] = action
35
- @request.env['REQUEST_METHOD'] = 'POST'
36
- @request.env['HTTP_CONTENT_TYPE'] = 'text/xml'
37
- @request.env['RAW_POST_DATA'] = encode_rpc_call(service_name, api_method_name, *args)
38
- case protocol
39
- when ActionWebService::Protocol::Soap::SoapProtocol
40
- soap_action = "/#{@controller.controller_name}/#{service_name}/#{public_method_name(service_name, api_method_name)}"
41
- @request.env['HTTP_SOAPACTION'] = soap_action
42
- when ActionWebService::Protocol::XmlRpc::XmlRpcProtocol
43
- @request.env.delete('HTTP_SOAPACTION')
44
- end
45
- end
29
+ def prepare_request(action, service_name, api_method_name, *args)
30
+ @request.recycle!
31
+ @request.request_parameters['action'] = action
32
+ @request.request_parameters['controller'] = @controller.class.name
33
+ @request.env['REQUEST_METHOD'] = 'POST'
34
+ @request.env['HTTP_CONTENT_TYPE'] = 'text/xml'
35
+ @request.env['RAW_POST_DATA'] = encode_rpc_call(service_name, api_method_name, *args)
36
+ case protocol
37
+ when ActionWebService::Protocol::Soap::SoapProtocol
38
+ soap_action = "/#{@controller.controller_name}/#{service_name}/#{public_method_name(service_name, api_method_name)}"
39
+ @request.env['HTTP_SOAPACTION'] = soap_action
40
+ when ActionWebService::Protocol::XmlRpc::XmlRpcProtocol
41
+ @request.env.delete('HTTP_SOAPACTION')
42
+ end
43
+ end
46
44
 
47
- def encode_rpc_call(service_name, api_method_name, *args)
48
- case @controller.web_service_dispatching_mode
49
- when :direct
50
- api = @controller.class.web_service_api
51
- when :delegated, :layered
52
- api = @controller.web_service_object(service_name.to_sym).class.web_service_api
53
- end
54
- protocol.register_api(api)
55
- method = api.api_methods[api_method_name.to_sym]
56
- raise ArgumentError, "wrong number of arguments for rpc call (#{args.length} for #{method.expects.length})" if method && method.expects && args.length != method.expects.length
57
- protocol.encode_request(public_method_name(service_name, api_method_name), args.dup, method.expects)
58
- end
45
+ def encode_rpc_call(service_name, api_method_name, *args)
46
+ case @controller.web_service_dispatching_mode
47
+ when :direct
48
+ api = @controller.class.web_service_api
49
+ when :delegated, :layered
50
+ api = @controller.web_service_object(service_name.to_sym).class.web_service_api
51
+ end
52
+ protocol.register_api(api)
53
+ method = api.api_methods[api_method_name.to_sym]
54
+ raise ArgumentError, "wrong number of arguments for rpc call (#{args.length} for #{method.expects.length})" if method && method.expects && args.length != method.expects.length
55
+ protocol.encode_request(public_method_name(service_name, api_method_name), args.dup, method.expects)
56
+ end
59
57
 
60
- def decode_rpc_response
61
- public_method_name, return_value = protocol.decode_response(@response.body)
62
- exception = is_exception?(return_value)
63
- raise exception if exception
64
- return_value
65
- end
58
+ def decode_rpc_response
59
+ public_method_name, return_value = protocol.decode_response(@response.body)
60
+ exception = is_exception?(return_value)
61
+ raise exception if exception
62
+ return_value
63
+ end
66
64
 
67
- def public_method_name(service_name, api_method_name)
68
- public_name = service_api(service_name).public_api_method_name(api_method_name)
69
- if @controller.web_service_dispatching_mode == :layered && protocol.is_a?(ActionWebService::Protocol::XmlRpc::XmlRpcProtocol)
70
- '%s.%s' % [service_name.to_s, public_name]
71
- else
72
- public_name
73
- end
74
- end
65
+ def public_method_name(service_name, api_method_name)
66
+ public_name = service_api(service_name).public_api_method_name(api_method_name)
67
+ if @controller.web_service_dispatching_mode == :layered && protocol.is_a?(ActionWebService::Protocol::XmlRpc::XmlRpcProtocol)
68
+ '%s.%s' % [service_name.to_s, public_name]
69
+ else
70
+ public_name
71
+ end
72
+ end
75
73
 
76
- def service_api(service_name)
77
- case @controller.web_service_dispatching_mode
78
- when :direct
79
- @controller.class.web_service_api
80
- when :delegated, :layered
81
- @controller.web_service_object(service_name.to_sym).class.web_service_api
82
- end
83
- end
74
+ def service_api(service_name)
75
+ case @controller.web_service_dispatching_mode
76
+ when :direct
77
+ @controller.class.web_service_api
78
+ when :delegated, :layered
79
+ @controller.web_service_object(service_name.to_sym).class.web_service_api
80
+ end
81
+ end
84
82
 
85
- def protocol
86
- if @protocol.nil?
87
- @protocol ||= ActionWebService::Protocol::Soap::SoapProtocol.create(@controller)
88
- else
89
- case @protocol
90
- when :xmlrpc
91
- @protocol = ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.create(@controller)
92
- when :soap
93
- @protocol = ActionWebService::Protocol::Soap::SoapProtocol.create(@controller)
94
- else
95
- @protocol
96
- end
97
- end
98
- end
83
+ def protocol
84
+ if @protocol.nil?
85
+ @protocol ||= ActionWebService::Protocol::Soap::SoapProtocol.create(@controller)
86
+ else
87
+ case @protocol
88
+ when :xmlrpc
89
+ @protocol = ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.create(@controller)
90
+ when :soap
91
+ @protocol = ActionWebService::Protocol::Soap::SoapProtocol.create(@controller)
92
+ else
93
+ @protocol
94
+ end
95
+ end
96
+ end
99
97
 
100
- def is_exception?(obj)
101
- case protocol
102
- when :soap, ActionWebService::Protocol::Soap::SoapProtocol
103
- (obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && \
104
- obj.detail.cause.is_a?(Exception)) ? obj.detail.cause : nil
105
- when :xmlrpc, ActionWebService::Protocol::XmlRpc::XmlRpcProtocol
106
- obj.is_a?(XMLRPC::FaultException) ? obj : nil
107
- end
108
- end
98
+ def is_exception?(obj)
99
+ case protocol
100
+ when :soap, ActionWebService::Protocol::Soap::SoapProtocol
101
+ (obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && \
102
+ obj.detail.cause.is_a?(Exception)) ? obj.detail.cause : nil
103
+ when :xmlrpc, ActionWebService::Protocol::XmlRpc::XmlRpcProtocol
104
+ obj.is_a?(XMLRPC::FaultException) ? obj : nil
109
105
  end
110
106
  end
111
107
  end
metadata CHANGED
@@ -1,59 +1,66 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keeguon-actionwebservice
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
- - Laurence A. Lee, Leon Breedt, Kent Sibilev
7
+ - Laurence A. Lee
8
+ - Leon Breedt
9
+ - Kent Sibilev
10
+ - Félix Bellanger
8
11
  autorequire: actionwebservice
9
12
  bindir: bin
10
13
  cert_chain: []
11
- date: 2013-04-04 00:00:00.000000000 Z
14
+ date: 2013-04-16 00:00:00.000000000 Z
12
15
  dependencies:
13
16
  - !ruby/object:Gem::Dependency
14
17
  name: activesupport
15
18
  requirement: !ruby/object:Gem::Requirement
16
19
  requirements:
17
- - - ~>
20
+ - - '>='
18
21
  - !ruby/object:Gem::Version
19
- version: '3.0'
22
+ version: '3.1'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ~>
27
+ - - '>='
25
28
  - !ruby/object:Gem::Version
26
- version: '3.0'
29
+ version: '3.1'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: actionpack
29
32
  requirement: !ruby/object:Gem::Requirement
30
33
  requirements:
31
- - - ~>
34
+ - - '>='
32
35
  - !ruby/object:Gem::Version
33
- version: '3.0'
36
+ version: '3.1'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - ~>
41
+ - - '>='
39
42
  - !ruby/object:Gem::Version
40
- version: '3.0'
43
+ version: '3.1'
41
44
  - !ruby/object:Gem::Dependency
42
45
  name: activerecord
43
46
  requirement: !ruby/object:Gem::Requirement
44
47
  requirements:
45
- - - ~>
48
+ - - '>='
46
49
  - !ruby/object:Gem::Version
47
- version: '3.0'
50
+ version: '3.1'
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - ~>
55
+ - - '>='
53
56
  - !ruby/object:Gem::Version
54
- version: '3.0'
57
+ version: '3.1'
55
58
  description: Adds WSDL/SOAP and XML-RPC web service support to Action Pack
56
- email: rubyjedi@gmail.com, bitserf@gmail.com, ksibilev@yahoo.com
59
+ email:
60
+ - rubyjedi@gmail.com
61
+ - bitserf@gmail.com
62
+ - ksibilev@yahoo.com
63
+ - felix.bellanger@gmail.com
57
64
  executables: []
58
65
  extensions: []
59
66
  extra_rdoc_files: []