我正在使用 Savon 库来获取一些 SOAP 请求。我在 IRB 和 Rails 应用程序中使用几乎相同的代码。当我运行 IRB 时,一切正常,但 Rails 在 savon 的do_request -> respond_with
方法中生成错误“nil:NilClass 没有方法 'to_hash'”。
这是我的代码(在 IRB 或 Rails 中运行时相同):
# setup Savon client for SOAP requests
client = Savon::Client.new "http://www.webservicex.net/country.asmx?WSDL"
# test if "webservicex.net" server is up and running
actions = client.wsdl.soap_actions
raise "SOAP server is down" if actions.nil? or actions.length <= 0
# get country list
resp = client.request :get_countries
raise "No response for countries" if resp.nil?
resp = resp[:get_countries_response][:get_countries_result]
没有任何异常出现,也没有执行“pinging server”以外的代码。
出了什么问题,我该如何解决?