Writing Web Service Client from WSDL

Writing Web Service Client from WSDL GeoIPService - GeoIPService enables you to easily look up countries by IP address / Context
Follow the steps:
1. Create a New Java Project called IPLocationFinder

2. Generate Client stub
Open command prompt and make a temporary directory called sei and switch into sei.
then type wsimport http://www.webservicex.net/geoipservice.asmx?WSDL.
It will generate .class files.
If you want to get a source files as well, you can use following command
wsimport -keep -s src http://www.webservicex.net/geoipservice.asmx?WSDL.
It will generate all the .class files as well as .java files.
Finally, you create package called net.webservicex into src folder in your project, and copy all the java files.
3. Create a class called IPLocationFinder
Now, you write the code to call web service.
Now,you pass the argument and run it.
The final output is United States

0 comments:

Post a Comment

Search This Blog

Powered by Blogger.