0
我正在使用Savon庫來獲取一些SOAP請求的工作。我在IRB和Rails應用程序中使用幾乎相同的代碼。當我運行IRB時,一切正常,但Rails會在savon的do_request -> respond_with
方法內生成錯誤「no method」to_hash'for nil:NilClass「。Savon在Rails應用程序中引發錯誤,但不在irb內
(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]
是例外的沒有復活,也沒有被執行的代碼遠比「執行ping服務器」。
怎麼了,我該如何解決這個問題?
感謝您的幫助。 – rubiii 2011-05-11 22:04:28