Global Services Integration
Ensure you have an account setup. You will need the Username, Password and WSDL location. Please note: Wherever<LatestWSDLVersion> is shown in Example Code below, please replace this with GlobalServices21a.wsdl.
If you are unsure of any of the details you can contact the helpdesk for more information.
Importing the WSDL (Maven)
There are many different ways of importing a WSDL into your program. Use whichever method you are most familiar with. This sample code uses JAXWS to import and generate the webservice objects with Maven. An example POM is provided below.<LatestWSDLVersion> file is downloaded and saved into “Project_Root/wsdl/<LatestWSDLVersion>”. Upon build JAXWS will generate all the web service objects and place them into “globalservices-alu-integration-example\target\jaxws\wsimport\java”.
The IDE may automatically exclude the target directory from the project. Go into the module settings and add the “target\jaxws\wsimport\java” as a source.
Creating the Service
In this example a service layer is created to handle the calls to the web service. First an interface is created. This helps separate the code out so the implementation can be changed without much consequence.Getting the Web Service
The requests are being sent with the this.getWebservice method. This method returns the webservice with the specified endpoint. See the below method:Managing Authentication Details and Session Tokens
The AuthenticationDetails class contains the username, authenticationToken, authenticationTime and some logic to refresh authenticationDetails and check the validity of the authenticationToken:Telephone Integration
The following code will expand on the examples to demonstrate an integration into the Global Telephone validation service. Sample Code The telephone lookup method:Bank Integration
The following code will expand on the examples to demonstrate an integration into the Bank Account validation service. Sample Code The bank account lookup method:AddressBase Premium
The following code will expand on the examples to demonstrate an integration into the AddressBase Premium capture service. Sample Code The AddressBase Premium lookup method:Matchcode Names
The following code will expand on the examples to demonstrate an integration into the Matchcode Names capture service. Sample Code The following Names lookup method formats the results with \t (tab) to make them more human readable:Matchcode Premium
Matchcode Premium allows the user to lookup consented telephone numbers for an individual, and also lookup references on social media. Sample code The sample code shows how to request the person information, and how to request the type of search required (the social flow type).Exception Handling
The exception handling is done here as we are outputting to the console we do not require access to any GUI objects. This also means the exception handling will work if doing an extended address lookup.Project Source Code
Download the source code here: idm-globalservices-integration-examplePowerSearch REST Integration
Next, we will take a look at several key parts of the Powersearch REST Client Application. Ensure you have an account setup. You will need the Username and Password If you are unsure of any of the details you can contact the helpdesk for more information.Service Layer (REST Client)
In this example a service layer is created to handle the calls to the REST Web Service. First an interface is created. This helps separate the code out so the implementation can be changed without much consequence. For instance, we will provide an implementation of a Rest Client using a concrete technology (Apache HttpClient), but the interface operations might be implemented by using any other technology. Next, the code for this Interface:Response Deserialization
The PowerSearch REST WebService returns the requested information either in XML or JSON format. This depends on the “Accept” header parameter value. To deal with that information in the Client Application it’s highly recommended to de-serialize the chunk of characters (XML or JSON) into some Data Transfer Objects. This makes easier work with the data. To de-serialize XML or JSON into Objects we need two things: A process to fill the Objects with data and the Objects to be filled. Keeping in mind the information structure returned by the Service, the Data Transfer Objects created to allocate it are as follows:Integration
Next, we will see 2 examples of integration and some aspects to take into account when integrating Powersearch REST Webservice. The first one will search for an address (or partial address) using Global Address operation, and the second one, given a full address, will search for geocode information using Geocode operation.Global Address Searching
Powersearch REST WebService offers the Global Address operation to find addresses. This operation accepts partial addresses so that the more accurate the address provided is the less addresses will be returned from the service. When the supplied address is accurate enough, the service will return the definitive address which can be formatted by using the format options (format parameter). The code to use Global Address Operation (through the Service Layer previously created) as follows:Geocode Searching
Powersearch REST WebService offers the Geocode operation to get geographical information for an address. The Address supplied to this operation must be accurate enough to be identified unequivocally. Otherwise, the WebService will return a 404 (No Matches found). Thus, a normal process of using Powersearch WebService might be to use Global Address operation (as many times as needed) until a definitive address is found and afterwards supply this address to the Geocode operation in order to get the geographical information. The code to use Geocode Operation (through the Service Layer previously created) is as follows:Authentication
Powersearch REST WebService uses HTTP Basic Authentication method. This means the client must send the credentials as a header parameter in every request to the Server (in the way the standard says). In the code supplied, this is done by using the Apache HttpClient library, which hides the way the credentials are sent to the server so that, once the username and password are provided, the rest is done automatically. Here is the code that uses Apache HttpClient library to provide the credentials:Http Status Codes Processing
As Powersearch is a REST WebService, the server status information after a request is provided as a HTTP Status code. The codes that could be returned by the service are: 200 - OK404 - Address or Country not found
400 - Bad Request (something wrong in the request)
401 - Unauthorized (no credentials or bad credentials supplied)
403 - Access Denied (good credentials, but user with incorrect permissions)
500 - Internal Server Error
Thus, it’s very useful for the client to process the returned status code in order to know exactly what went wrong with the request. Note that if everything is OK, and some matches for the search are returned (Global Address or Geocode), 200 status code will be returned. Also, if an error code other than 200 is returned by the server, some information will be added to the response, which can be found in the information field. Below, the code to process the returned HTTP status codes:

