cleaning up. soap is so slow. ugh.

cat-town
Dan Buch 13 years ago
parent 343a0cbd74
commit f20b74d2f9

@ -1,15 +1,30 @@
require 'savon'
require 'pp'
require 'tmpdir'
WSDL = File.expand_path('./uszip.wsdl', File.dirname(__FILE__))
def main
#client = Savon.client('http://www.webservicex.net/uszip.asmx?WSDL')
logfile = File.join(Dir.tmpdir, 'uszip.log')
HTTPI.log = false
Savon.configure do |config|
config.log = true
config.log_level = :debug
config.logger = Logger.new(logfile)
end
r = get_info_by_zip((ARGV.first || 90210).to_i)
puts "#{r[:city]}, #{r[:state]} #{r[:zip]} " <<
"(#{r[:area_code]}) [#{r[:time_zone]}]"
end
def get_info_by_zip(zipcode)
client = Savon.client(WSDL)
response = client.request(:tns, :get_info_by_zip) do
soap.body = {"USZip" => 15220}
response = client.request(:get_info_by_zip) do
soap.body = {"USZip" => zipcode}
end
pp response.to_hash
res = response.to_hash[:get_info_by_zip_response][:get_info_by_zip_result]
res[:new_data_set][:table]
end
if $0 == __FILE__

Loading…
Cancel
Save