I am trying to export a Ruby structure through XML-RPC. However, I am having some problems trying to call a method from a class that was not added directly as a handler to the XML-RPC server. See my example below:
I have a test Ruby XML-RPC server as follows:
require "xmlrpc/server"
class ExampleBar
def bar()
return "hello world!"
end
end
class ExampleFoo
def foo()
return ExampleBar.new
end
def test()
return "test!"
end
end
s = XMLRPC::Server.new( 9090 )
s.add_introspection
s.add_handler( "example", ExampleFoo.new )
s.serve
And I have a Python XML-RPC test client as follows:
import xmlrpclib
s = xmlrpclib.Server( "http://127.0.0.1:9090/" )
print s.example.foo().bar()
I would expect the python client to print “hello world!”. as this is the equivalent of the following ruby code:
example = ExampleFoo.new
puts example.foo().bar()
However, it generates an error: "xmlrpclib.ProtocolError: <ProtocolError for 127.0.0.1:9090/: 500 Internal Server Error>".
print s.example.test () is working fine.
, ExampleBar , , "" , bar() .
XML-RPC ?
, , ; , XML-RPC, ?