diff options
Diffstat (limited to 'actionwebservice/lib/action_web_service')
-rw-r--r-- | actionwebservice/lib/action_web_service/scaffolding.rb | 30 | ||||
-rw-r--r-- | actionwebservice/lib/action_web_service/templates/scaffolds/parameters.rhtml | 4 |
2 files changed, 27 insertions, 7 deletions
diff --git a/actionwebservice/lib/action_web_service/scaffolding.rb b/actionwebservice/lib/action_web_service/scaffolding.rb index 3978a6ab48..aad15a0979 100644 --- a/actionwebservice/lib/action_web_service/scaffolding.rb +++ b/actionwebservice/lib/action_web_service/scaffolding.rb @@ -63,22 +63,23 @@ module ActionWebService protocol_name = @params['protocol'] ? @params['protocol'].to_sym : :soap case protocol_name when :soap - protocol = Protocol::Soap::SoapProtocol.new + @protocol = Protocol::Soap::SoapProtocol.new when :xmlrpc - protocol = Protocol::XmlRpc::XmlRpcProtocol.new + @protocol = Protocol::XmlRpc::XmlRpcProtocol.new end @invocation_cgi = @request.respond_to?(:cgi) ? @request.cgi : nil bm = Benchmark.measure do - protocol.register_api(@scaffold_service.api) + @protocol.register_api(@scaffold_service.api) params = @params['method_params'] ? @params['method_params'].dup : nil params = @scaffold_method.cast_expects(params) - @method_request_xml = protocol.encode_request(@scaffold_method.public_name, params, @scaffold_method.expects) - new_request = protocol.encode_action_pack_request(@scaffold_service.name, @scaffold_method.public_name, @method_request_xml) - new_request.parameters.update(@request.parameters) + method_name = public_method_name(@scaffold_service.name, @scaffold_method.public_name) + @method_request_xml = @protocol.encode_request(method_name, params, @scaffold_method.expects) + new_request = @protocol.encode_action_pack_request(@scaffold_service.name, @scaffold_method.public_name, @method_request_xml) + prepare_request(new_request, @scaffold_service.name, @scaffold_method.public_name) @request = new_request dispatch_web_service_request @method_response_xml = @response.body - method_name, obj = protocol.decode_response(@method_response_xml) + method_name, obj = @protocol.decode_response(@method_response_xml) return if handle_invocation_exception(obj) @method_return_value = @scaffold_method.cast_returns(obj) end @@ -123,6 +124,21 @@ module ActionWebService @performed_render = false end + def public_method_name(service_name, method_name) + if web_service_dispatching_mode == :layered && @protocol.is_a?(ActionWebService::Protocol::XmlRpc::XmlRpcProtocol) + service_name + '.' + method_name + else + method_name + end + end + + def prepare_request(request, service_name, method_name) + request.parameters.update(@request.parameters) + if web_service_dispatching_mode == :layered && @protocol.is_a?(ActionWebService::Protocol::Soap::SoapProtocol) + request.env['HTTP_SOAPACTION'] = "/\#{controller_name()}/\#{service_name}/\#{method_name}" + end + end + def handle_invocation_exception(obj) exception = nil if obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && obj.detail.cause.is_a?(Exception) diff --git a/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.rhtml b/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.rhtml index f06b0986b4..e7b5f47f03 100644 --- a/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.rhtml +++ b/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.rhtml @@ -9,6 +9,8 @@ <%= select_tag 'protocol', options_for_select([['SOAP', 'soap'], ['XML-RPC', 'xmlrpc']], @params['protocol']) %> </p> +<% if @scaffold_method.expects %> + <strong>Method Parameters:</strong><br /> <% @scaffold_method.expects.each do |type| %> <p> @@ -17,6 +19,8 @@ </p> <% end %> +<% end %> + <%= submit_tag "Invoke" %> <p> |