SOAP Web Services -Writing a Web service Client: Calling the Service

Nagendra Reddy
Mar 24, 2022

--

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>

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response