diff options
author | Leon Breedt <bitserf@gmail.com> | 2005-04-02 21:03:36 +0000 |
---|---|---|
committer | Leon Breedt <bitserf@gmail.com> | 2005-04-02 21:03:36 +0000 |
commit | aaea48fe9826b9e5d2d5b92795a297b8f238c58d (patch) | |
tree | e7c01c7f95d467f837c1f96d58dac74c3c902610 /actionwebservice/lib/action_web_service/test_invoke.rb | |
parent | aa09c770e9b5400683be11952673017295246de7 (diff) | |
download | rails-aaea48fe9826b9e5d2d5b92795a297b8f238c58d.tar.gz rails-aaea48fe9826b9e5d2d5b92795a297b8f238c58d.tar.bz2 rails-aaea48fe9826b9e5d2d5b92795a297b8f238c58d.zip |
* collapse 'ws' back into protocols, it just added complexity and indirection, and was hard to extend.
* extract casting into seperate support file
* ensure casting always does the right thing for return values, should fix interoperability issues with Ecto and possibly other XML-RPC clients
* add functional unit tests for scaffolding
* represent signature items with classes instead of symbols/Class objects, much more flexible
* tweak logging to always show casted versions of parameters and return values, if possible.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1072 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionwebservice/lib/action_web_service/test_invoke.rb')
-rw-r--r-- | actionwebservice/lib/action_web_service/test_invoke.rb | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/actionwebservice/lib/action_web_service/test_invoke.rb b/actionwebservice/lib/action_web_service/test_invoke.rb index 5d364e4225..c22ca618dc 100644 --- a/actionwebservice/lib/action_web_service/test_invoke.rb +++ b/actionwebservice/lib/action_web_service/test_invoke.rb @@ -21,7 +21,7 @@ module Test # :nodoc: # invoke the specified layered API method on the correct service def invoke_layered(service_name, method_name, *args) - if protocol == :soap + if protocol.is_a?(ActionWebService::Protocol::Soap::SoapProtocol) raise "SOAP protocol support for :layered dispatching mode is not available" end prepare_request('api', service_name, method_name, *args) @@ -37,10 +37,10 @@ module Test # :nodoc: @request.env['HTTP_CONTENT_TYPE'] = 'text/xml' @request.env['RAW_POST_DATA'] = encode_rpc_call(service_name, api_method_name, *args) case protocol - when :soap + when ActionWebService::Protocol::Soap::SoapProtocol soap_action = "/#{@controller.controller_name}/#{service_name}/#{public_method_name(service_name, api_method_name)}" @request.env['HTTP_SOAPACTION'] = soap_action - when :xmlrpc + when ActionWebService::Protocol::XmlRpc::XmlRpcProtocol @request.env.delete('HTTP_SOAPACTION') end end @@ -52,19 +52,18 @@ module Test # :nodoc: when :delegated, :layered api = @controller.web_service_object(service_name.to_sym).class.web_service_api end + protocol.register_api(api) method = api.api_methods[api_method_name.to_sym] - method.register_types(marshaler) - method.encode_rpc_call(marshaler, encoder, args.dup, :method_name => public_method_name(service_name, api_method_name)) + protocol.encode_request(public_method_name(service_name, api_method_name), args.dup, method.expects) end def decode_rpc_response - public_method_name, return_value = encoder.decode_rpc_response(@response.body) - result = marshaler.unmarshal(return_value).value + public_method_name, return_value = protocol.decode_response(@response.body) unless @return_exceptions - exception = is_exception?(result) + exception = is_exception?(return_value) raise exception if exception end - result + return_value end def public_method_name(service_name, api_method_name) @@ -86,25 +85,7 @@ module Test # :nodoc: end def protocol - @protocol ||= :soap - end - - def marshaler - case protocol - when :soap - @soap_marshaler ||= WS::Marshaling::SoapMarshaler.new 'urn:ActionWebService' - when :xmlrpc - @xmlrpc_marshaler ||= WS::Marshaling::XmlRpcMarshaler.new - end - end - - def encoder - case protocol - when :soap - @soap_encoder ||= WS::Encoding::SoapRpcEncoding.new 'urn:ActionWebService' - when :xmlrpc - @xmlrpc_encoder ||= WS::Encoding::XmlRpcEncoding.new - end + @protocol ||= ActionWebService::Protocol::Soap::SoapProtocol.new end def is_exception?(obj) |