3

我刚刚在 Rails 3.2.11 上安装了 Savon 2.0.2。当我尝试在控制台中创建新客户端时,我得到TypeError: can't convert String into Hash

1.9.3-p362 :003 > client = Savon::Client.new("http://www.webservicex.net/uszip.asmx?WSDL")
TypeError: can't convert String into Hash
    from /Users/jasonswett/.rvm/gems/ruby-1.9.3-p362/gems/savon-2.0.2/lib/savon/options.rb:49:in `merge'
    from /Users/jasonswett/.rvm/gems/ruby-1.9.3-p362/gems/savon-2.0.2/lib/savon/options.rb:49:in `initialize'
    from /Users/jasonswett/.rvm/gems/ruby-1.9.3-p362/gems/savon-2.0.2/lib/savon/client.rb:10:in `new'
    from /Users/jasonswett/.rvm/gems/ruby-1.9.3-p362/gems/savon-2.0.2/lib/savon/client.rb:10:in `initialize'
    from (irb):3:in `new'
    from (irb):3
    from /Users/jasonswett/.rvm/gems/ruby-1.9.3-p362/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
    from /Users/jasonswett/.rvm/gems/ruby-1.9.3-p362/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
    from /Users/jasonswett/.rvm/gems/ruby-1.9.3-p362/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

知道为什么会发生这种情况吗?这是一个全新的、几乎是普通的 Rails 应用程序,所以我不明白可能出了什么问题。

4

2 回答 2

7

尝试:

client = Savon::Client.new(wsdl: "http://www.webservicex.net/uszip.asmx?WSDL")

或者

client = Savon.client(wsdl: "http://www.webservicex.net/uszip.asmx?WSDL")
于 2013-01-15T18:57:22.040 回答
0

由于肥皂需要哈希而不是字符串,因此您可以在哈希键、值格式的参数中添加哈希

Rails 中描述哈希键的旧方法

client = Savon.client(:wsdl=> "http://www.webservicex.net/uszip.asmx?WSDL")

在 Rails 中描述哈希的新方法

client = Savon.client(wsdl: "http://www.webservicex.net/uszip.asmx?WSDL")
于 2013-01-29T08:10:46.303 回答