我有一个 XMLRPC 服务器正在运行:
#!/usr/bin/env python
from SimpleXMLRPCServer import SimpleXMLRPCServer
import subprocess
import os
def testls():
retcode=subprocess.call(["ls", "/etc"])
return retcode
server = SimpleXMLRPCServer(('192.168.15.20',8888),logRequests=True)
server.register_function(testls)
server.register_introspection_functions()
try:
server.serve_forever()
finally:
server.server_close()
我需要能够从 ruby 客户端调用它。根据我的发现。似乎应该是这样的:
require xmlrpc/client
server = XMLRPC::Client.new2("http://192.168.15.20:8888/")
但它返回以下内容,这表明它无法访问该服务。
=> #<XMLRPC::Client:0x2ab0f5caacf8 @parser=nil, @timeout=30, @path="/", @password=nil, @http_header_extra=nil, @use_ssl=false, @host="192.168.15.20", @user=nil, @proxy_port=nil, @auth=nil, @cookie=nil, @create=nil, @port=8888, @http=#<Net::HTTP 192.168.15.20:8888 open=false>, @proxy_host=nil, @http_last_response=nil>
我在以下方面取得了更好的成功,但我无法调用该方法:
irb(main):069:0> server = XMLRPC::Client::Proxy.new("http://192.168.15.20","8888")
=> #<XMLRPC::Client::Proxy:0x2ab0f5c4ef48 @args=[], @server="http://192.168.15.20", @meth=:call, @prefix="8888.">
irb(main):070:0> s = server.call('system.listMethods')
NoMethodError: undefined method `call' for "http://192.168.15.20":String
from /usr/lib/ruby/1.8/xmlrpc/client.rb:608:in `send'
from /usr/lib/ruby/1.8/xmlrpc/client.rb:608:in `method_missing'
from (irb):70
from :0
调用从 Ruby 到 Python XML-RPC 服务器的调用的适当代码是什么?