Geolocator web service integration notes
Note: The underlying geolocator database is made freely available to Name On The Net clients
Web Services Background
Web services are receiving much attention recently, the respected Gartner Group boldly
stating they will become "the mainstream business application architecture" by 2007. This seems likely
given they are an integral part of Microsoft's .NET strategy. A web service can be
defined as a software component addressable with a URL and accessible over the internet. Unlike earlier
distributed architectures which were either proprietory or overly complex: DCOM, RMI and CORBA, web services
are based on simple open standards defined under the auspices of w3c. Web services introduce
a new set of acronyms: SOAP (Simple Object Access Protocol), WSDL (Web Services Description Language),
UDDI (Universal Discovery Description and Integration), and believe it or not
DISCO (Discovery of Web Services) and ROPE (Remote Object Proxy Engine) make an appearance.
Document purpose
The purpose of this document is to demonstrate how to use the www.nameonthe.net 'geolocater' web service.
The 'geolocator' web service determines an IP address' country of origin. This can be used to
customise your web sites behaviour in realtime, an obvious use would be to deliver custom content to particular
markets.
Java Integration
The Apache Axis project is a open source SOAP implementation which can be downloaded from http://ws.apache.org/axis.
It also implements JAXRPC (Java API for XML-based RPC) which conforms to JSR 224 (Java Specification Request).
JAXRPC presents a higher level interface to work with Web services, 'protecting' the programmer from having to
understand the finer details of SOAP. Download the binary package and place the distributed jar files into
your classpath. The code below demonstrates how to invoke a web service with the name 'IPLookup'
with the operation name 'getCountryByIP'. The web service will return null if it cannot determine the country code.
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Service;
... Code ...
try {
Service service = new Service();
Call call = (Call) service.createCall();
String host =
"http://www.nameonthe.net/webservices/services/IPLookup?wsdl";
// Set where the web service is located
call.setTargetEndpointAddress(host);
// Set the service and operation name
call.setOperationName(new QName("IPLookup", "getCountryByIP"));
// Invoke the operation
String countrycode = (String)call.invoke(new String[] {"217.207.14.248"});
} catch (ServiceException e) {
// Your exception handling code
}
... Code ...
Perl Integration
The SOAP::Lite module needs to be installed for the following example to work.
use SOAP::Lite;
print SOAP::Lite
->service('http://www.nameonthe.net/webservices/services/IPLookup?wsdl')
->getCountryByIP('217.207.14.248');
This prints the result from the lookup.
Version: 1.0
Date: 14/09/2004