3

我正在使用一个 Python 脚本,它使用xmlrpclib

import xmlrpclib
srv = xmlrpclib.ServerProxy("http://demo.myslice.info:7080/", allow_none=True)

# authentication token
auth = {"AuthMethod": "password", "Username": "guest", "AuthString": "guest"}
ret = srv.Get(auth, "slice", [["slice_hrn", '=', "ple.upmc.myslicedemo"]], {}, ["slice_hrn"])
print ret

我想使用 Ruby 进行类似的 XML-RPC 调用。为此,我使用了以下代码:

require "xmlrpc/client"
require "pp"

XMLRPC::Config.module_eval do
    remove_const :ENABLE_NIL_PARSER
    const_set :ENABLE_NIL_PARSER, true
end

ret = XMLRPC::Client.new2("http://demo.myslice.info:7080/")

auth = {"AuthMethod" => "password", "Username" => "guest", "AuthString" => "guest"}

pp ret.call("Get", auth, "slice", {"slice_hrn" => "ple.upmc.myslicedemo"}, ["slice_hrn"])

当我运行这个 Ruby 脚本时,我收到以下错误:

.../xmlrpc/client.rb:414:in `call': error (XMLRPC::FaultException)

我能做些什么来解决这个错误?

4

1 回答 1

0

错误在转换中。我使用字典而不是列表中的列表。我解决了它:

require "xmlrpc/client"
require "pp"

XMLRPC::Config.module_eval do
    remove_const :ENABLE_NIL_PARSER
    const_set :ENABLE_NIL_PARSER, true
end

ret = XMLRPC::Client.new2("http://demo.myslice.info:7080/")

auth = {"AuthMethod" => "password", "Username" => "guest", "AuthString" => "guest"}

pp ret.call("Get", auth, "slice", [["slice_hrn", "=" ,"ple.upmc.myslicedemo"]], {}, ["slice_hrn"])
于 2012-11-09T20:25:43.647 回答