I have a XMLRPC server running:
#!/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()
I need to be able to call it from a ruby client. From what I have found. it seems that it should be this:
require xmlrpc/client
server = XMLRPC::Client.new2("http://192.168.15.20:8888/")
But it returns the following, which suggests that it is not able to reach the service.
=> #<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>
I had better success with the following, but I was not able to invoke the method:
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
What is the appropriate code to invoke a call from Ruby to a Python XML-RPC Server?