Installation and Getting Started Guide (On-Premises)

Installation and Getting Started Guide (On-Premises)

Example: Initializing Informatica Address Verification from a Java Based Implementation

Example: Initializing Informatica Address Verification from a Java Based Implementation

Before you can start processing addresses using Address Verification in a Java based implementation, you must initialize Address Verification by calling
AddressDoctor.initialize()
. After you initialize Address Verification, you can call other functions such as
AddressDoctor.getAddressObject()
. After you complete address processing, call
AddressDoctor.releaseAddressObject()
and
AddressDoctor.deinitialize()
to release the address object and close the Address Verification process, respectively.
The following example shows sample Java code that contains
AddressDoctor.initialize()
,
AddressDoctor.getAddressObject()
,
AddressDoctor.releaseAddressObject()
, and
AddressDoctor.deinitialize()
function calls. The sample code also contains one Singapore address to validate.
private static AddressObject m_oAO; public static void main(String[] args) { int iLastError = 0; String sResultXML = ""; try { AddressDoctor.initialize( "<?xml version='1.0' encoding='UTF-16' ?>"+ "<!DOCTYPE SetConfig SYSTEM 'SetConfig.dtd'>"+ "<SetConfig><General WriteXMLEncoding='UTF-16' />"+ " <UnlockCode>
(Enter Code here)
</UnlockCode>"+ " <DataBase CountryISO3='ALL' Type='BATCH_INTERACTIVE'"+ " Path='/ADDB' PreloadingType='NONE' />"+ "</SetConfig>", null, "<?xml version='1.0' encoding='UTF-16' ?>"+ "<!DOCTYPE SetConfig SYSTEM 'Parameters.dtd'>"+ "<Parameters WriteXMLEncoding='UTF-16'>"+ " <Input Encoding='UTF-16' />"+ " <Result Encoding='UTF-16' />"+ "</Parameters>", null); iLastError = AddressDoctor.getLastError(); System.out.println("Using AddressDoctor version: " + AddressDoctor.getVersion()); System.out.println("Init returned " + iLastError); } catch (AddressDoctorException ex) { System.out.println("Exception while initializing "+ "AddressDoctor: " + ex.toString()); System.out.println("Further processing not possible, "+ "application ends!"); return; } try { m_oAO = AddressDoctor.getAddressObject(); } catch (AddressDoctorException ex) { System.out.println("Exception while trying to get an "+ "AddressObject: " + ex.toString()); System.out.println("Further processing not possible, "+ "application ends!"); try { AddressDoctor.deinitialize(); } catch (AddressDoctorException ex2){} return; } try { m_oAO.setInputDataXML( "<?xml version='1.0' encoding='UTF-16'?>"+ "<!DOCTYPE InputData SYSTEM InputData.dtd'>"+ "<InputData>"+ "<AddressElements>"+ " <Key>4711</Key>"+ " <Country Item='1' Type='NAME'>SGP</Country>"+ " <Locality Item='1' Type='COMPLETE'>Singapore</Locality>"+ " <PostalCode Item='1' Type='FORMATTED'>048624</PostalCode>"+ " <Street Item='1' Type='COMPLETE'>Raffles Place</Street>"+ " <Number Item='1' Type='COMPLETE'>80</Number>"+ " <Building Item='1' Type='COMPLETE'>#50-01 UOB Plaza 1</Building>"+ " <Organization Item='1' Type='NAME'>AddressDoctor GmbH</Organization>"+ "</AddressElements>"+ "</InputData>"); } catch (Exception ex) { System.out.println("Data could not be assigned! Closing "+ "application: " + ex.toString()); try { AddressDoctor.releaseAddressObject(m_oAO); AddressDoctor.deinitialize(); } catch (AddressDoctorException ex2){} return; } try { AddressDoctor.process(m_oAO); iLastError = AddressDoctor.getLastError(); System.out.println("Process returned " + iLastError); } catch (AddressDoctorException ex) { System.out.println("Exception during process: " + ex.toString()); } if (iLastError == 0) { try { sResultXML = m_oAO.getResultXML(); } catch (AddressDoctorException ex) { System.out.println("Exception while trying to get "+ "ResultXML: " + ex.toString()); return; } System.out.println(sResultXML); } try { AddressDoctor.releaseAddressObject(m_oAO); AddressDoctor.deinitialize(); } catch (AddressDoctorException ex) { System.out.println("Exception while releasing the AO and "+ "de-initializing AddressDoctor: " + ex.toString()); } } }

0 COMMENTS

We’d like to hear from you!