SOAP Web Services -Writing a Web service Client: Calling the Service
Step 1:
Find the WSDL which is available in global, Here i am selected
http://wsgeoip.lavasoft.com/ipservice.asmx?WSDL
Step 2:
Create a folder in your PC (GEO), navigate to folder using terminal / command prompt. Enter the below command to generate the WSDL classes.
GEO>wsimport -keep “http://wsgeoip.lavasoft.com/ipservice.asmx?WSDL"
Note: Java Should be installed before you run above command.
Step 3:
Once the classes generated, you need to find the Stub Class, Here “GeoIPSService” is the name of the SOAP Stub.

Step 4:
Open GEO folder in your IntelliJ or eclipse, Add one Main class called TestGeoIP.java, As shown below
public class TestGeoIP {
public static void main(String args[]){
String ipAddress = "142.250.195.174";
GeoIPService geoIPService = new GeoIPService();
GeoIPServiceSoap geoIPServiceSoap = geoIPService.getGeoIPServiceSoap();
System.out.println(geoIPServiceSoap.getIpLocation(ipAddress));
}
}
Step 5:
Execute the program and see the output as below:
<GeoIP><Country>US</Country><State>CA</State></GeoIP>