提交 64271335 编写于 作者: L Leon Breedt

support SOAP invocation of layered services in scaffolding too, fix bug when

method takes no parameters


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1098 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 1155ea0a
...@@ -63,22 +63,23 @@ def #{action_name}_submit ...@@ -63,22 +63,23 @@ def #{action_name}_submit
protocol_name = @params['protocol'] ? @params['protocol'].to_sym : :soap protocol_name = @params['protocol'] ? @params['protocol'].to_sym : :soap
case protocol_name case protocol_name
when :soap when :soap
protocol = Protocol::Soap::SoapProtocol.new @protocol = Protocol::Soap::SoapProtocol.new
when :xmlrpc when :xmlrpc
protocol = Protocol::XmlRpc::XmlRpcProtocol.new @protocol = Protocol::XmlRpc::XmlRpcProtocol.new
end end
@invocation_cgi = @request.respond_to?(:cgi) ? @request.cgi : nil @invocation_cgi = @request.respond_to?(:cgi) ? @request.cgi : nil
bm = Benchmark.measure do 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 = @params['method_params'] ? @params['method_params'].dup : nil
params = @scaffold_method.cast_expects(params) params = @scaffold_method.cast_expects(params)
@method_request_xml = protocol.encode_request(@scaffold_method.public_name, params, @scaffold_method.expects) method_name = public_method_name(@scaffold_service.name, @scaffold_method.public_name)
new_request = protocol.encode_action_pack_request(@scaffold_service.name, @scaffold_method.public_name, @method_request_xml) @method_request_xml = @protocol.encode_request(method_name, params, @scaffold_method.expects)
new_request.parameters.update(@request.parameters) 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 @request = new_request
dispatch_web_service_request dispatch_web_service_request
@method_response_xml = @response.body @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) return if handle_invocation_exception(obj)
@method_return_value = @scaffold_method.cast_returns(obj) @method_return_value = @scaffold_method.cast_returns(obj)
end end
...@@ -123,6 +124,21 @@ def reset_invocation_response ...@@ -123,6 +124,21 @@ def reset_invocation_response
@performed_render = false @performed_render = false
end 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) def handle_invocation_exception(obj)
exception = nil exception = nil
if obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && obj.detail.cause.is_a?(Exception) if obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && obj.detail.cause.is_a?(Exception)
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
<%= select_tag 'protocol', options_for_select([['SOAP', 'soap'], ['XML-RPC', 'xmlrpc']], @params['protocol']) %> <%= select_tag 'protocol', options_for_select([['SOAP', 'soap'], ['XML-RPC', 'xmlrpc']], @params['protocol']) %>
</p> </p>
<% if @scaffold_method.expects %>
<strong>Method Parameters:</strong><br /> <strong>Method Parameters:</strong><br />
<% @scaffold_method.expects.each do |type| %> <% @scaffold_method.expects.each do |type| %>
<p> <p>
...@@ -17,6 +19,8 @@ ...@@ -17,6 +19,8 @@
</p> </p>
<% end %> <% end %>
<% end %>
<%= submit_tag "Invoke" %> <%= submit_tag "Invoke" %>
<p> <p>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册