Monday 22 August 2016

CONSUME ONLINE WEB SERVICES USING JAVA

Step 1: Online webservice

http://www.webservicex.net/geoipservice.asmx?wsdl


Step 2:  In your command prompt


              >mkdir sei
              >cd sei/

              set your jdk bin path
                       > set path=" "
                       > wsimport  http://www.webservicex.net/geoipservice.asmx?wsdl

Step 3:  After that the package created in sei folder.it contains all class files.

Step 4: Then Convert class file to java file using the below commands

              sei> wsimport -keep -s src http://www.webservicex.net/geoipservice.asmx?wsdl

Step 5: After that import all the java files in our project.



                         

Step 6: Create a class file

IPFinder.java

package net.webservicex;
import java.util.*;
public class IPfinder {
public static void main(String arg[])
{
// if(arg.length!=1)
// {
// System.out.println("welcome");
// }
// else
// {

        System.out.println("Enter the ip address");
Scanner sc=new Scanner(System.in);

String ipAddress=sc.next();
GeoIPService ipservice=new GeoIPService();
GeoIPServiceSoap geoipservicesoap=ipservice.getGeoIPServiceSoap();
GeoIP geoip=geoipservicesoap.getGeoIP(ipAddress);
System.out.println(geoip.getCountryName());
}
}

             
         

No comments:

Post a Comment