【问题标题】:Savon raises error inside Rails app, but not inside irbSavon 在 Rails 应用程序中引发错误,但在 irb 中没有
【发布时间】:2011-05-11 17:13:15
【问题描述】:

我正在使用 Savon 库来处理一些 SOAP 请求。我在 IRB 和 Rails 应用程序中使用几乎相同的代码。当我运行 IRB 时,一切正常,但 Rails 在 savon 的 do_request -> respond_with 方法中生成错误“no method 'to_hash' for nil:NilClass”。

这是我的代码(在 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”以外的代码。

出了什么问题,我该如何解决?

【问题讨论】:

    标签: ruby-on-rails ruby soap savon httpi


    【解决方案1】:

    httpi gem 有问题 - https://github.com/rubiii/savon/issues/163 只需使用0.9.1 版本即可。

    【讨论】:

      猜你喜欢
      • 2015-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多