我使用的是使用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)
我该怎么做才能解决此错误?
答案 0 :(得分: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"])