metro web service

Metro web service by default comes with Java 1.6 or later versions. To see your java supports metro services or not go to java installation directory>jdk>bin>look for wsimport.exe . If present then your java supports Metro web services.
View details about web service in my previous post webServices
Example for metro service Consumer using eclipse Ide
Creating a Service Consumer for GeoIPService(which takes input as ip address and returns the Country code and Country name of IP Address).Here GeoipService is the service provider
For details visit:http://www.webservicex.net/geoipservice.asmx?op=GetGeoIP

Follow the following steps :

Download wsdl file:

Open the following link in web Browser http://www.webservicex.net/geoipservice.asmx?WSDL

Save it as geoipservice.wsdl

Now Open eclipse ide >new java project>Copy wsdl file(geoipservices.wsdl) to your project>right click on wsdl file>select Web services> Generate Client> Scroll the bar to select develop option in web service client window> Finish

The above steps will generate ws -runtime classes .
















Write the main class to invoke the service as shown below

package org.pack.service;

import net.webservicex.www.GeoIP;
import net.webservicex.www.GeoIPServiceLocator;
import net.webservicex.www.GeoIPServiceSoap;

public class IPFindClient {
public static void main(String[] args) throws Exception {

String ipAddress="174.125.236.69";
GeoIPServiceLocator service=new GeoIPServiceLocator();
GeoIPServiceSoap port=service.getGeoIPServiceSoap();
GeoIP geoIP=port.getGeoIP(ipAddress);
System.out.println(geoIP.getCountryName());
}

}


save the program and run it.