blob: 122f62434fca143aba58a6fb9dbaf34eefacc131 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
require 'xmlrpc/marshal'
module WS
module Encoding
class XmlRpcError < WSError
end
class XmlRpcEncoding < AbstractEncoding
def encode_rpc_call(method_name, params)
XMLRPC::Marshal.dump_call(method_name, *params)
end
def decode_rpc_call(obj)
method_name, params = XMLRPC::Marshal.load_call(obj)
i = 0
params = params.map do |value|
param = XmlRpcDecodedParam.new("param#{i}", value)
i += 1
param
end
[method_name, params]
end
def encode_rpc_response(method_name, return_value)
if return_value.nil?
XMLRPC::Marshal.dump_response(true)
else
XMLRPC::Marshal.dump_response(return_value)
end
end
def decode_rpc_response(obj)
return_value = XMLRPC::Marshal.load_response(obj)
[nil, XmlRpcDecodedParam.new('return', return_value)]
end
end
class XmlRpcDecodedParam
attr :param
def initialize(name, value)
info = ParamInfo.new(name, value.class)
@param = Param.new(value, info)
end
end
end
end
|