require 'savon' require 'pp' require 'tmpdir' WSDL = File.expand_path('./uszip.wsdl', File.dirname(__FILE__)) def main 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(: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 if $0 == __FILE__ main end