2 # Load required libraries
3 require 'soap/wsdlDriver'
6 # Monkey patch WSDL parser to stop it moaning
15 # Provide interface to Quova geolocation service
18 # Access details for WSDL description
19 WSDL_URL="https://webservices.quova.com/OnDemand/GeoPoint/v1/default.asmx?WSDL"
20 WSDL_USER = APP_CONFIG['quova_username']
21 WSDL_PASS = APP_CONFIG['quova_password']
27 InvalidCredentials = 2
36 # Create SOAP endpoint
37 @@soap = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver
38 @@soap.options["protocol.http.basic_auth"] << [WSDL_URL, WSDL_USER, WSDL_PASS]
41 # Accessor for SOAP endpoint
47 # Class representing geolocation details for an IP address
49 def initialize(ip_address)
50 @ipinfo = Quova::soap.GetIpInfo(:ipAddress => ip_address)
54 @ipinfo["GetIpInfoResult"]["Response"]["Status"].to_i
58 @ipinfo["GetIpInfoResult"]["Location"]["Country"]["Name"]
61 def country_confidence
62 @ipinfo["GetIpInfoResult"]["Location"]["Country"]["Confidence"]