Вопрос

I'm reading railscast #290 that are going with savon version 1. So I tried to replace command for version 2, but I couldn't do it.

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

I replaced the commands like these.

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

How can I set namespace web and body parameter USZIP and 90210?

Это было полезно?

Решение

try this (www.webservicex.net is not very reliable though):

#!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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top