diff options
author | Leon Breedt <bitserf@gmail.com> | 2005-03-29 12:31:39 +0000 |
---|---|---|
committer | Leon Breedt <bitserf@gmail.com> | 2005-03-29 12:31:39 +0000 |
commit | b94bd32f3116b469b48400382dbc964bf17994d1 (patch) | |
tree | 91752d7e0f49916e5ed2b9e015815c6dc06b4366 /actionwebservice/lib/action_web_service/protocol | |
parent | 715715aed443a027fccbac995cd5404eaeabaf53 (diff) | |
download | rails-b94bd32f3116b469b48400382dbc964bf17994d1.tar.gz rails-b94bd32f3116b469b48400382dbc964bf17994d1.tar.bz2 rails-b94bd32f3116b469b48400382dbc964bf17994d1.zip |
first pass of web service scaffolding. add ability to quickly generate an
action pack request for a protocol, add missing log_error when we fail to parse
protocol messages. add RDoc for scaffolding and functional testing.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1037 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionwebservice/lib/action_web_service/protocol')
3 files changed, 62 insertions, 2 deletions
diff --git a/actionwebservice/lib/action_web_service/protocol/abstract.rb b/actionwebservice/lib/action_web_service/protocol/abstract.rb index ed50a6ffde..0ff4feef84 100644 --- a/actionwebservice/lib/action_web_service/protocol/abstract.rb +++ b/actionwebservice/lib/action_web_service/protocol/abstract.rb @@ -7,10 +7,64 @@ module ActionWebService # :nodoc: 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') end + + def protocol_client(api, protocol_name, endpoint_uri, options) + end + + def create_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 + request.env['RAW_POST_DATA'] = raw_body + request.env['REQUEST_METHOD'] = 'POST' + request.env['HTTP_CONTENT_TYPE'] = 'text/xml' + request + end + end + + class SimpleActionPackRequest < ActionController::AbstractRequest + 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 class Request # :nodoc: diff --git a/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb b/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb index 253812b5e2..5e56748ae3 100644 --- a/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb +++ b/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb @@ -20,11 +20,17 @@ module ActionWebService # :nodoc: Request.new(self, method_name, params, service_name) end - def protocol_client(api, protocol_name, endpoint_uri, options) + def protocol_client(api, protocol_name, endpoint_uri, options={}) return nil unless protocol_name == :soap ActionWebService::Client::Soap.new(api, endpoint_uri, options) end + def create_action_pack_request(service_name, public_method_name, raw_body, options={}) + request = super + request.env['HTTP_SOAPACTION'] = '/soap/%s/%s' % [service_name, public_method_name] + request + end + private def has_valid_soap_action?(request) return nil unless request.method == :post diff --git a/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb b/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb index 37ef16c12f..f8ff12cfa3 100644 --- a/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb +++ b/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb @@ -18,7 +18,7 @@ module ActionWebService # :nodoc: Request.new(self, method_name, params, service_name) end - def protocol_client(api, protocol_name, endpoint_uri, options) + def protocol_client(api, protocol_name, endpoint_uri, options={}) return nil unless protocol_name == :xmlrpc ActionWebService::Client::XmlRpc.new(api, endpoint_uri, options) end |