cleaning up. soap is so slow. ugh.
This commit is contained in:
parent
343a0cbd74
commit
f20b74d2f9
@ -1,15 +1,30 @@
|
|||||||
require 'savon'
|
require 'savon'
|
||||||
|
|
||||||
require 'pp'
|
require 'pp'
|
||||||
|
require 'tmpdir'
|
||||||
|
|
||||||
WSDL = File.expand_path('./uszip.wsdl', File.dirname(__FILE__))
|
WSDL = File.expand_path('./uszip.wsdl', File.dirname(__FILE__))
|
||||||
|
|
||||||
def main
|
def main
|
||||||
#client = Savon.client('http://www.webservicex.net/uszip.asmx?WSDL')
|
logfile = File.join(Dir.tmpdir, 'uszip.log')
|
||||||
client = Savon.client(WSDL)
|
HTTPI.log = false
|
||||||
response = client.request(:tns, :get_info_by_zip) do
|
Savon.configure do |config|
|
||||||
soap.body = {"USZip" => 15220}
|
config.log = true
|
||||||
|
config.log_level = :debug
|
||||||
|
config.logger = Logger.new(logfile)
|
||||||
end
|
end
|
||||||
pp response.to_hash
|
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(:get_info_by_zip) do
|
||||||
|
soap.body = {"USZip" => zipcode}
|
||||||
|
end
|
||||||
|
res = response.to_hash[:get_info_by_zip_response][:get_info_by_zip_result]
|
||||||
|
res[:new_data_set][:table]
|
||||||
end
|
end
|
||||||
|
|
||||||
if $0 == __FILE__
|
if $0 == __FILE__
|
||||||
|
Loading…
Reference in New Issue
Block a user