Permalink
Browse files

support SOAP invocation of layered services in scaffolding too, fix b…

…ug when

method takes no parameters


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1098 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 1155ea0 commit 642713358400c186a41856c5464a232a20d0ebd1 @bitserf bitserf committed Apr 5, 2005
@@ -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)
@@ -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>

0 comments on commit 6427133

Please sign in to comment.