如何为savon版本2设置参数

时间:2013-11-28 03:45:20

标签: soap wsdl savon

我正在阅读使用savon版本1的railscast#290。 所以我试图替换版本2的命令,但我做不到。

http://railscasts.com/episodes/290-soap-with-savon?view=asciicast

我替换了这些命令。

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

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

ver1 client.wsdl.soap_actions

ver2 client.operations

ver1 client.request :web, :get_info_by_zip, body: { "USZIP" => "90210" }

ver2 client.call(:get_info_by_zip) # need more

如何设置名称空间web和正文参数USZIP90210

1 个答案:

答案 0 :(得分:3)

试试这个(www.webservicex.net虽然不太可靠):

#!ruby

require 'savon'

WSDL_URL = 'http://www.webservicex.net/uszip.asmx?wsdl'

client = Savon.client(wsdl: WSDL_URL,
                      log: true, # set true to switch on logging
                      log_level: :debug,
                      pretty_print_xml: true)

zip = ARGV[0] || "10004"

response = client.call(:get_info_by_zip, message: {"USZip"=>zip})

print response