ruby-on-railsrubysoapsavonhttpi

Savon raises error inside Rails app, but not inside irb


I'm using Savon library to get some SOAP requests work. And i'm using almost the same code within IRB and Rails application. When i'm running IRB everything works as it should, but Rails generate error "no method 'to_hash' for nil:NilClass" inside savon's do_request -> respond_with methods.

Here's my code (the same when running it within IRB or 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]

None of that exceptions is risen nor code far than 'pinging server' is executed.

What's wrong and how could i fix that?


Solution

  • It's problem with httpi gem - https://github.com/rubiii/savon/issues/163 Just use 0.9.1 version.