www.pudn.com > google_examples.zip > MyZipCodeChecker.java, change:2002-05-05,size:1407b


import com.trwest.*; 
import java.net.URL; 
 
/* 
 
 MyZipCodeChecker.java 
 
 This is a test client that invokes a zipcode lookup service. 
 For more information, see http://upload.eraserver.net/trwest/trwest_zip4/zip4.asmx.  
 
 Sample output: 
 
 E:\test>java MyZipCodeChecker 
 Looking up zip code for this address: 
 62 Downer Ave. 
 Hingham, MA 
 Zipcode: 02043-1103 
 Looking up city and state for zip code 02043-1103 
 City: HINGHAM 
 State: MA 
 
*/ 
 
public class MyZipCodeChecker { 
	 
	public static void main(String[] args) { 
		try { 
			Service1Locator locator = new Service1Locator(); 
			String serviceURL = locator.getService1SoapAddress(); 
			Service1SoapStub soapstub = new Service1SoapStub(new URL(serviceURL), null); 
 
			String address = "62 Downer Ave."; 
			String city = "Hingham"; 
			String state = "MA"; 
			System.out.println("Looking up zip code for this address:"); 
			System.out.println(address + "\n" + city + ", " + state); 
 
			String zip = soapstub.findZipPlus4(address, city, state); 
			System.out.println("Zipcode: " + zip); 
 
			System.out.println("Looking up city and state for zip code " + zip); 
			CityState cityState = soapstub.findCityState("02043"); 
			System.out.println("City: " + cityState.getCity()); 
			System.out.println("State: " + cityState.getState()); 
 
		} catch (Exception e) { 
			e.printStackTrace(); 
			System.exit(0); 
		} 
 
	} 
 
}