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/protocol/abstract.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/protocol/abstract.rb')
-rw-r--r-- | actionwebservice/lib/action_web_service/protocol/abstract.rb | 93 |
1 files changed, 51 insertions, 42 deletions
diff --git a/actionwebservice/lib/action_web_service/protocol/abstract.rb b/actionwebservice/lib/action_web_service/protocol/abstract.rb index 0ff4feef84..70b922ce73 100644 --- a/actionwebservice/lib/action_web_service/protocol/abstract.rb +++ b/actionwebservice/lib/action_web_service/protocol/abstract.rb @@ -3,22 +3,11 @@ module ActionWebService # :nodoc: class ProtocolError < ActionWebServiceError # :nodoc: end - class AbstractProtocol - attr :marshaler - attr :encoder - - def unmarshal_request(ap_request) - end - - def marshal_response(method, return_value) - body = method.encode_rpc_response(marshaler, encoder, return_value) - Response.new(body, 'text/xml') + class AbstractProtocol # :nodoc: + def decode_action_pack_request(action_pack_request) end - def protocol_client(api, protocol_name, endpoint_uri, options) - end - - def create_action_pack_request(service_name, public_method_name, raw_body, options={}) + def encode_action_pack_request(service_name, public_method_name, raw_body, options={}) klass = options[:request_class] || SimpleActionPackRequest request = klass.new request.request_parameters['action'] = service_name.to_s @@ -27,50 +16,30 @@ module ActionWebService # :nodoc: request.env['HTTP_CONTENT_TYPE'] = 'text/xml' request end - end - class SimpleActionPackRequest < ActionController::AbstractRequest - def initialize - @env = {} - @qparams = {} - @rparams = {} - @cookies = {} - reset_session + def decode_request(raw_request, service_name) end - def query_parameters - @qparams + def encode_request(method_name, params, param_types) end - def request_parameters - @rparams + def decode_response(raw_response) end - def env - @env - end - - def host - '' - end - - def cookies - @cookies + def encode_response(method_name, return_value, return_type) end - def session - @session + def protocol_client(api, protocol_name, endpoint_uri, options) end - def reset_session - @session = {} + def register_api(api) end end class Request # :nodoc: attr :protocol attr :method_name - attr :method_params + attr_accessor :method_params attr :service_name attr_accessor :api attr_accessor :api_method @@ -88,10 +57,50 @@ module ActionWebService # :nodoc: class Response # :nodoc: attr :body attr :content_type + attr :return_value - def initialize(body, content_type) + def initialize(body, content_type, return_value) @body = body @content_type = content_type + @return_value = return_value + end + end + + class SimpleActionPackRequest < ActionController::AbstractRequest # :nodoc: + def initialize + @env = {} + @qparams = {} + @rparams = {} + @cookies = {} + reset_session + end + + def query_parameters + @qparams + end + + def request_parameters + @rparams + end + + def env + @env + end + + def host + '' + end + + def cookies + @cookies + end + + def session + @session + end + + def reset_session + @session = {} end end end |