From 1155ea0aa3c25b4683c6343162cd49dbe0fec094 Mon Sep 17 00:00:00 2001 From: Leon Breedt Date: Tue, 5 Apr 2005 21:37:48 +0000 Subject: initial go at making :layered dispatching generate WSDL for SOAP, and have :layered process SOAP method calls correctly as well, may be unstable git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1097 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/action_web_service/dispatcher/abstract.rb | 14 ++++++++++--- .../dispatcher/action_controller_dispatcher.rb | 23 +++++++++++++++------- 2 files changed, 27 insertions(+), 10 deletions(-) (limited to 'actionwebservice/lib/action_web_service/dispatcher') diff --git a/actionwebservice/lib/action_web_service/dispatcher/abstract.rb b/actionwebservice/lib/action_web_service/dispatcher/abstract.rb index 975120212f..1d8715a8f7 100644 --- a/actionwebservice/lib/action_web_service/dispatcher/abstract.rb +++ b/actionwebservice/lib/action_web_service/dispatcher/abstract.rb @@ -52,9 +52,17 @@ module ActionWebService # :nodoc: 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 + case invocation.protocol + when Protocol::Soap::SoapProtocol + soap_action = request.protocol_options[:soap_action] + if soap_action && soap_action =~ /^\/\w+\/(\w+)\// + invocation.service_name = $1 + end + when Protocol::XmlRpc::XmlRpcProtocol + if request.method_name =~ /^([^\.]+)\.(.*)$/ + public_method_name = $2 + invocation.service_name = $1 + end end end case web_service_dispatching_mode diff --git a/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb b/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb index 822939a101..a999be9b7c 100644 --- a/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +++ b/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb @@ -185,7 +185,7 @@ module ActionWebService # :nodoc: api = self.class.web_service_api web_service_name = controller_class_name.sub(/Controller$/, '').underscore apis[web_service_name] = [api, register_api(api, marshaler)] - when :delegated + when :delegated, :layered self.class.web_services.each do |web_service_name, info| service = web_service_object(web_service_name) api = service.class.web_service_api @@ -244,7 +244,7 @@ module ActionWebService # :nodoc: api = values[0] api.api_methods.each do |name, method| gen = lambda do |msg_name, direction| - xm.message('name' => msg_name) do + xm.message('name' => message_name_for(api_name, msg_name)) do sym = nil if direction == :out returns = method.returns @@ -271,8 +271,8 @@ module ActionWebService # :nodoc: xm.portType('name' => port_name) do api.api_methods.each do |name, method| xm.operation('name' => method.public_name) do - xm.input('message' => "typens:#{method.public_name}") - xm.output('message' => "typens:#{method.public_name}Response") + xm.input('message' => "typens:" + message_name_for(api_name, method.public_name)) + xm.output('message' => "typens:" + message_name_for(api_name, "#{method.public_name}Response")) end end end @@ -284,9 +284,9 @@ module ActionWebService # :nodoc: api.api_methods.each do |name, method| xm.operation('name' => method.public_name) do case web_service_dispatching_mode - when :direct, :layered + when :direct soap_action = soap_action_base + "/api/" + method.public_name - when :delegated + when :delegated, :layered soap_action = soap_action_base \ + "/" + api_name.to_s \ + "/" + method.public_name @@ -315,7 +315,7 @@ module ActionWebService # :nodoc: port_name = port_name_for(global_service_name, api_name) binding_name = binding_name_for(global_service_name, api_name) case web_service_dispatching_mode - when :direct + when :direct, :layered binding_target = 'api' when :delegated binding_target = api_name.to_s @@ -336,6 +336,15 @@ module ActionWebService # :nodoc: "#{global_service}#{service.to_s.camelize}Binding" end + def message_name_for(api_name, message_name) + mode = web_service_dispatching_mode + if mode == :layered || mode == :delegated + api_name.to_s + '-' + message_name + else + message_name + end + end + def register_api(api, marshaler) bindings = {} traverse_custom_types(api, marshaler) do |binding| -- cgit v1.2.3