1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb
Leon Breedt 100015cd80 Make all custom types and method calls are declared in the 'urn:ActionWebService'
namespace as a default, fixes SOAP marshaling for .NET, a regression since the merge.

Make array annotation be recursive in WS::Marshaling::SoapMarshaling, this makes
typed arrays buried in nested structures still be annotated correctly.

Support :layered dispatching mode for XML-RPC namespaced method names.

Change WS::ParamInfo.create signature to require type_binding, and update all
uses of this.

Restore #default_api_method functionality, fixes a regression since the merge.

Fix marshalling of ActiveRecord::Base derivatives, fixes a regression since the merge.

This changeset closes #676, #677, and #678.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@811 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-02-27 21:21:40 +00:00

48 lines
1.5 KiB
Ruby

module ActionWebService # :nodoc:
module Protocol # :nodoc:
module XmlRpc # :nodoc:
def self.included(base)
base.register_protocol(XmlRpcProtocol)
end
class XmlRpcProtocol # :nodoc:
attr :marshaler
def initialize
@encoder = WS::Encoding::XmlRpcEncoding.new
@marshaler = WS::Marshaling::XmlRpcMarshaler.new
end
def unmarshal_request(ap_request)
method_name, params = @encoder.decode_rpc_call(ap_request.raw_post)
params = params.map{|x| @marshaler.unmarshal(x)}
service_name = ap_request.parameters['action']
Request.new(self, method_name, params, service_name)
rescue
nil
end
def marshal_response(method_name, return_value, signature_type)
if !return_value.nil? && signature_type
type_binding = @marshaler.register_type(signature_type)
info = WS::ParamInfo.create(signature_type, type_binding, 0)
return_value = @marshaler.marshal(WS::Param.new(return_value, info))
else
return_value = nil
end
body = @encoder.encode_rpc_response(method_name, return_value)
Response.new(body, 'text/xml')
end
def register_signature_type(spec)
nil
end
def protocol_client(api, protocol_name, endpoint_uri, options)
return nil unless protocol_name == :xmlrpc
ActionWebService::Client::XmlRpc.new(api, endpoint_uri, options)
end
end
end
end
end