diff options
author | Leon Breedt <bitserf@gmail.com> | 2005-02-27 21:21:40 +0000 |
---|---|---|
committer | Leon Breedt <bitserf@gmail.com> | 2005-02-27 21:21:40 +0000 |
commit | 100015cd806e31578a03ba23ffbc12c093118a26 (patch) | |
tree | 20cd8b5f8fd8cbfb60f2b8d2f309c0c259889d50 /actionwebservice/lib/action_web_service/dispatcher/abstract.rb | |
parent | 19dddf24a63bd8a715ca47955963ba77d174d830 (diff) | |
download | rails-100015cd806e31578a03ba23ffbc12c093118a26.tar.gz rails-100015cd806e31578a03ba23ffbc12c093118a26.tar.bz2 rails-100015cd806e31578a03ba23ffbc12c093118a26.zip |
Make all custom types and method calls are declared in the 'urn:ActionWebService'
namespace as a default, fixes SOAP marshaling for .NET, a regression since the merge.
Make array annotation be recursive in WS::Marshaling::SoapMarshaling, this makes
typed arrays buried in nested structures still be annotated correctly.
Support :layered dispatching mode for XML-RPC namespaced method names.
Change WS::ParamInfo.create signature to require type_binding, and update all
uses of this.
Restore #default_api_method functionality, fixes a regression since the merge.
Fix marshalling of ActiveRecord::Base derivatives, fixes a regression since the merge.
This changeset closes #676, #677, and #678.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@811 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionwebservice/lib/action_web_service/dispatcher/abstract.rb')
-rw-r--r-- | actionwebservice/lib/action_web_service/dispatcher/abstract.rb | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/actionwebservice/lib/action_web_service/dispatcher/abstract.rb b/actionwebservice/lib/action_web_service/dispatcher/abstract.rb index b7560afc87..641f291533 100644 --- a/actionwebservice/lib/action_web_service/dispatcher/abstract.rb +++ b/actionwebservice/lib/action_web_service/dispatcher/abstract.rb @@ -19,7 +19,7 @@ module ActionWebService # :nodoc: case web_service_dispatching_mode when :direct web_service_direct_invoke(invocation) - when :delegated + when :delegated, :layered web_service_delegated_invoke(invocation) end end @@ -27,7 +27,11 @@ module ActionWebService # :nodoc: def web_service_direct_invoke(invocation) @method_params = invocation.method_ordered_params return_value = self.__send__(invocation.api_method_name) - returns = invocation.returns ? invocation.returns[0] : nil + if invocation.api.has_api_method?(invocation.api_method_name) + returns = invocation.returns ? invocation.returns[0] : nil + else + returns = return_value.class + end invocation.protocol.marshal_response(invocation.public_method_name, return_value, returns) end @@ -44,29 +48,43 @@ module ActionWebService # :nodoc: end def web_service_invocation(request) + public_method_name = request.method_name invocation = Invocation.new invocation.protocol = request.protocol invocation.service_name = request.service_name + if web_service_dispatching_mode == :layered + if request.method_name =~ /^([^\.]+)\.(.*)$/ + public_method_name = $2 + invocation.service_name = $1 + end + end + invocation.public_method_name = public_method_name case web_service_dispatching_mode when :direct invocation.api = self.class.web_service_api invocation.service = self - when :delegated - invocation.service = web_service_object(request.service_name) rescue nil + when :delegated, :layered + invocation.service = web_service_object(invocation.service_name) rescue nil unless invocation.service - raise(DispatcherError, "failed to instantiate service #{invocation.service_name}") + raise(DispatcherError, "service #{invocation.service_name} not available") end invocation.api = invocation.service.class.web_service_api end - public_method_name = request.method_name - unless invocation.api.has_public_api_method?(public_method_name) - raise(DispatcherError, "no such method '#{public_method_name}' on API #{invocation.api}") + if invocation.api.has_public_api_method?(public_method_name) + invocation.api_method_name = invocation.api.api_method_name(public_method_name) + else + if invocation.api.default_api_method.nil? + raise(DispatcherError, "no such method '#{public_method_name}' on API #{invocation.api}") + else + invocation.api_method_name = invocation.api.default_api_method.to_s.to_sym + end + end + unless invocation.service.respond_to?(invocation.api_method_name) + raise(DispatcherError, "no such method '#{public_method_name}' on API #{invocation.api} (#{invocation.api_method_name})") end - invocation.public_method_name = public_method_name - invocation.api_method_name = invocation.api.api_method_name(public_method_name) info = invocation.api.api_methods[invocation.api_method_name] - invocation.expects = info[:expects] - invocation.returns = info[:returns] + invocation.expects = info ? info[:expects] : nil + invocation.returns = info ? info[:returns] : nil if invocation.expects i = 0 invocation.method_ordered_params = request.method_params.map do |param| @@ -83,7 +101,7 @@ module ActionWebService # :nodoc: params = [] invocation.expects.each do |spec| type_binding = invocation.protocol.register_signature_type(spec) - info = WS::ParamInfo.create(spec, i, type_binding) + info = WS::ParamInfo.create(spec, type_binding, i) params << WS::Param.new(invocation.method_ordered_params[i], info) i += 1 end @@ -96,10 +114,15 @@ module ActionWebService # :nodoc: invocation.method_ordered_params = [] invocation.method_named_params = {} end + if invocation.returns + invocation.returns.each do |spec| + invocation.protocol.register_signature_type(spec) + end + end invocation end - class Invocation + class Invocation # :nodoc: attr_accessor :protocol attr_accessor :service_name attr_accessor :api |