diff --git a/actionwebservice/lib/action_web_service/scaffolding.rb b/actionwebservice/lib/action_web_service/scaffolding.rb index 3978a6ab489320336735d35d7501adfb8c3afa0d..aad15a09799e558a07d54a36887c31065a988382 100644 --- a/actionwebservice/lib/action_web_service/scaffolding.rb +++ b/actionwebservice/lib/action_web_service/scaffolding.rb @@ -63,22 +63,23 @@ def #{action_name}_submit 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 @@ def reset_invocation_response @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 f06b0986b4c6d2491347a76988b970ce613610d1..e7b5f47f03a0809a85f0fa98716313048fe0c6eb 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']) %>
+<% if @scaffold_method.expects %> + Method Parameters:@@ -17,6 +19,8 @@
<% end %> +<% end %> + <%= submit_tag "Invoke" %>