Example 81 : Verify addresses
This example shows you how to verify addresses.
package com.metapack.dm.test; import com.metapack.deliverymanager.client.Address; import com.metapack.deliverymanager.client.VerifiedAddress; import com.metapack.deliverymanager.client.webservices.InformationService; public class Example81 extends ExampleBase{ public void run() throws Exception { InformationService service = createInformationService(); Address address = new Address(); address.setLine1("something invalid"); address.setLine2("London"); address.setPostCode("EC1R 4PF"); address.setCountryCode("GBR"); address.setCompanyName(""); //find similar addresses to the one that we have created Address[] addresses = service.findSimilarAddresses(address); //Verify all the returned addresses VerifiedAddress[] verAddList = service.verifyAddresses(addresses); if(verAddList!=null){ for(int i=0;i<verAddList.length;i++){ if(verAddList!=null){ if(!verAddList[i].getStatus().equals("OK")){ System.out.println("Error: Unable to verify address! : " + verAddList[i].toString()); }else{ System.out.println("Verified : " + verAddList[i].getCompanyName() + "," + verAddList[i].getLine1() + "," + verAddList[i].getLine2() + "," + verAddList[i].getLine3() + "," + verAddList[i].getLine4() + "," + verAddList[i].getPostCode() + "," + verAddList[i].getCountryCode()); } } } } } public static void main(String[] args) { Example81 instance = new Example81(); try { instance.run(); } catch( Exception e ) { e.printStackTrace(); } } }

