Skip to content

Integration Example: 

Multi-Threaded Java Wrapper For IdM GlobalServices

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.

IdMClientWrapper facilities

The module globalservices-capture-trace-verify-wrapper-lib exposes a main class IdMClientWrapper. This class has three public static methods which can be used to submit requests to IdMGlobalServices.

  • performCaptureRequest()
  • performTraceRequest()
  • performVerifyRequest()

All these methods have a similar signature - they only differ in the ProfileRequest type of the last argument.

Note: the Verify functionality is not currently used by any of the Matchcode360 or Connexus web services.

Capture:

public static profileresponse performcapturerequest(
  final string username, 
  final string password, 
  final string endpoint, 
  int timeoutms, 
  final profilerequestcapture request)
 throws
  timeoutexception, 
  exception;

Trace:

public static profileresponse performtracerequest(
  final string username, 
  final string password, 
  final string endpoint, 
  int timeoutms, 
  final profilerequesttrace request) 
 throws
  timeoutexception, 
  exception;

Verify:

Note: the Verify functionality is not currently used by any of the Matchcode360 or Connexus web  services.  Use the Capture method for email and telephone validation, for example.

public static profileresponse performverifyrequest(
  final string username, 
  final string password, 
  final string endpoint, 
  int timeoutms, 
  final profilerequestverify request)
 throws
  timeoutexception, 
  exception;

Method Parameters

The parameters for these calls are as follows:

Parameter Type Description
username String The full username for the IdM account (e.g. username@domain)
password String The plain-text password for the IdM account (e.g. pAssW0rd)
endpoint String The URL for IdM Global Services
(normally https://idmp.gb.co.uk/idm-globalservices-ws/<LatestWSDLVersion>)
timeoutMS int Timeout in millisecond that the application should allow while waiting for an available client (e.g. 1000)
request ProfileRequestCapture or
ProfileRequestTrace or
ProfileRequestVerify
The ProfileRequest of the appropriate type containing the request details.


All the methods return a ProfileResponse instance.

Wrapper configuration

The IdMClientWrapper has a further static method which may be used to set the size of the pool of connections; the default pool size is 100. Any change to the pool size should be made in the application setup, and before any connections are used.

public static void setmaxconnections(int maxconnections);

Making a Capture Request

The following illustrates how the performCaptureRequest() method may be used for capture requests.

Create the main request object

The request details are held within an instance of ProfileRequestCapture, defined in the IdMGlobalServices WSDL. As a mimimum, the following three elements of the ProfileRequestCapture instance should be populated:

Element Type Description
customerReference String A reference that can be used to track the particular request (e.g. MyOrgRequest 23)
profileGuid String Profile to execute detailing which data sets to use. See the individual services documentation for details. Some examples are given below:
Profile GUID
UK Address Premise 6C49BC44-C104-41b2-BB62-2AE45A09DD54
UK Address Street Level C6356DD8-1CBA-4371-BE94-D5E08F1C777E
Global Telephone (Full) web service 454F13CA-8C71-40D6-9FEF-A88D821C99E4
Global Telephone (Rapid) web service 315559EB-94DD-49B8-8277-FEEB42CD6820
Email Validation web service 20B3F459-7D04-42AD-B7E2-AA1D5FE07E82
Global Bank Validation web service 39944560-4137-489A-A72D-64F0F3524B08
requestData ProfileRequestCaptureData The details of the request

Create the request data object

The request details are held within an instance of ProfileRequestCaptureData, defined in the IdMGlobalServices WSDL. The options element should be populated, together with one of the following, depending on the chosen profile:

Element Type Description
address IdmDataSearchAddress The address information (e.g. postcode, building number) for an address lookup profile
telephone List<IdmDataCaptureTelephone> A list containing one or more mobile or landline telephone numbers for a telephone validation profile
email List<String> A list containing one or more email addresses for an email validation profile
bank List<IdMDataCaptureBank> A list containing one or more bank details for an bank validation profile

 

The general approach to setting up the request is:

  1. Create an instance of IdmRequestOptions and populate as required.
  2. Create an instance of IdmDataSearchAddress, or List of telephone, email or bank details and populate as required.
  3. Create an instance of ProfileRequestCaptureData, and set the options and the address, telephone, email or bank element.
  4. Create an instance of ProfileRequestCapture, and set the customerReference, profileGuid and requestData elements.

Making the request call

Once the profile request has been set up, the request is submitted to IdM Global Services by calling the appropriate static method of IdMClientWrapper, with the user credentials, endpoint, timeout and request object. The calling application should be prepared to handle any TimeoutException or general Exception which may be thrown and, as good practice, check in case the returned ProfileResponse object is null before attempting to parse it.

Parsing the response

The ProfileResponse structure contains the results for an operation performed against a profile.

Type: ProfileResponse

Field Name Type Description
Field Name Type Description
profileHeader ProfileHeader Contains the Profile information for the results of the query
profileResponses ProfileResponseDetails Response data to the query


The ProfileResponseDetails structure contains the results for an operation performed against a product/data service in the Profile. It is possible to call multiple products in a single profile; in this case there will be multiple ProfileResponseDetails structures, one for each product.

Type: ProfileResponseDetails

Field Name Type Description
transactionGuid String Unique transaction identifier for the component e.g. Address Lookup component
componentName String Name of the component
componentStatus Enum SUCCESS, FAILURE, INSUFFICIENTCRITERIA, NA
componentAction String Component Action
responseType Enum CAPTURE
invoice DataLicenceInvoice List of charges for the query
captureResponse CaptureResponse Data from a component returning data e.g. Address lookup data
validateResponse ValidateResponse Data from a component returning validation responses e.g. Telephone Validation service


The CaptureResponse structure contains response records for a particular component/product. The data is held in a standard format across all products. The data structure is a flexible set of arrays designed to represent the data in a way that reflects the records in context of the search. The arrangement of the data will depend on the product in question. For more information on the layout of the response data please refer to the corresponding product documentation.

Type: CaptureResponse

Field Name Type Description
resultStatus Enum NA, INSUFFICIENTCRITERIA, NONE, SINGLE, MULTIPLE, PICKLIST, VERIFY
recordsReturned Int Number individual of records returned e.g. number of addresses
moreData Boolean More data on the server
totalRecordCount Int Total records from the query
totalPages Int Pagination - Total pages
responseCount Int Number of groups of responses returned
response CaptureResponseData Response data


The ValidateResponse structure contains response records for a particular component/product. The data is held in a standard format across all products. For more information on the layout of the response data please refer to the corresponding product documentation.

Type: ValidateResponse

Field Name Type Description
resultStatus Enum NA, INSUFFICIENTCRITERIA, NONE, SINGLE, MULTIPLE, PICKLIST, VERIFY
recordsReturned Int Number individual of records returned e.g. number of addresses
responseCount Int Number of group of response returned
response ValidateResponseData Response data

Typical Options

Typical options may be set up with the code below.

protected idmrequestoptions createidmrequestoptions() {
     idmrequestoptions idmrequestoptions = new idmrequestoptions();
     idmrequestoptions.setoffset(0);
     idmrequestoptions.setmaxreturn(10);
     idmrequestoptions.setaddressenvelopeformat("a4p");
     idmrequestoptions.setaddresssearchlevel(enumaddresslevel.premise);
      idmrequestoptions.setaddresssearchtype(enumaddresssearchtype.register);
     idmrequestoptions.setcasing(enumcasing.mixed);
     return idmrequestoptions;
}

UK Address Postcode Lookup

The whole process for performing a simple UK postcode-address lookup is illustrated below. The postcode to be looked up is provided in the String variable postcode.

// the url of idm globalservices v15b
final string endpoint_url = <br>  "https://idmp.gb.co.uk/idm-globalservices-ws/<latestwsdlversion>";
// profile guid for uk address lookups
final string address_profile_guid = "6c49bc44-c104-41b2-bb62-2ae45a09dd54";
// maximum time to wait for a connection to become available from the pool
final int timeout_ms = 10000;
 
// create the request
// first, we need a profilerequestcapture object to hold all the information
profilerequestcapture profilerequestcapture = new profilerequestcapture();
 
// within the profilerequestcapture, data is held in a profilerequestcapturedata object
profilerequestcapturedata profilerequestcapturedata = new profilerequestcapturedata();
 
// setup some basic options
idmrequestoptions idmrequestoptions = createidmrequestoptions();
// put those options into the capture data
profilerequestcapturedata.setoptions(idmrequestoptions);
 
// for an address lookup, we need a search address object
idmdatasearchaddress idmdatasearchaddress = new idmdatasearchaddress();
// in this case, we just have the postcode
idmdatasearchaddress.setpostcode(postcode);
// put the address into the capture data
profilerequestcapturedata.setaddress(idmdatasearchaddress);
 
// now put the capture data into the overall request
profilerequestcapture.setrequestdata(profilerequestcapturedata);
// set the configuration id of the configuration we are licensed for (usually 1)
profilerequestcapture.setconfigurationid(1);
// set a descriptive reference
profilerequestcapture.setcustomerreference("gbg sample code");
 
// important: set the profile we are going to use - in this case for uk address web service
profilerequestcapture.setprofileguid(address_profile_guid);
 
 
// now make the call using a static method on the idmclientwrapper
//   this is a capture request.
//
//   we pass in the authentication credentials, the actual globalservices wsdl url,
//        a timeout limit in millisecond,
//        and the request itself.
//
//   we expect back a profileresponse object.
 
try {
   system.out.println("postcode address lookup running ...");
   profileresponse profileresponse = idmclientwrapper
     .performcapturerequest(
        username,
        password,
        endpoint_url,
        timeout_ms,
        profilerequestcapture);
   system.out.println("... postcode address lookup has returned.");
 
   // disassemble the response to see what happened
   system.out.println("results from the postcode address lookup:");
   profileresponsedisassembler.disassemble(profileresponse);
} catch (exception e) {
    // in case something went wrong
    e.printstacktrace();
}
system.out.println("postcode address lookup complete.");

Telephone Validation

The whole process for performing a simple telephone validation is illustrated below. There is a mobile telephone number in the String variable mobile, and a landline telephone number in the String variable landline.

// the url of idm globalservices v15b
final string endpoint_url = "https://idmp.gb.co.uk/idm-globalservices-ws/<latestwsdlversion>";
// profile guid for global telephone validation
final string telephone_profile_guid = "454f13ca-8c71-40d6-9fef-a88d821c99e4";
// maximum time to wait for a connection to become available from the pool
final int timeout_ms = 10000;
 
 
// create the request
// first, we need a profilerequestcapture object to hold all the information
profilerequestcapture profilerequestcapture = new profilerequestcapture();
 
// within the profilerequestcapture, data is held in a profilerequestcapturedata object
profilerequestcapturedata profilerequestcapturedata = new profilerequestcapturedata();
 
// setup some basic options
idmrequestoptions idmrequestoptions = createidmrequestoptions();
// put those options into the capture data
profilerequestcapturedata.setoptions(idmrequestoptions);
 
// for an global telephone validation lookup, we need a list of telephone objects
list<idmdatacapturetelephone> listoftelephone = new arraylist<idmdatacapturetelephone>();
// add the mobile
if ((null != mobile) && !mobile.isempty()) {
idmdatacapturetelephone phone = new idmdatacapturetelephone();
phone.setnumber(mobile);
phone.settype(enumtelephone.mobile);
listoftelephone.add(phone);
}
// add the landline
if ((null != landline) && !landline.isempty()) {
idmdatacapturetelephone phone = new idmdatacapturetelephone();
phone.setnumber(landline);
phone.settype(enumtelephone.landline);
listoftelephone.add(phone);
}
// put the list of telephones into the capture data
profilerequestcapturedata.gettelephone().addall(listoftelephone);
 
// now put the capture data into the overall request
profilerequestcapture.setrequestdata(profilerequestcapturedata);
// set the configuration id of the configuration we are licensed for (usually 1)
profilerequestcapture.setconfigurationid(1);
// set a descriptive reference
profilerequestcapture.setcustomerreference("gbg sample code");
 
// important: set the profile we are going to use - in this case for global telephone validation web service
profilerequestcapture.setprofileguid(telephone_profile_guid);
 
 
// now make the call using a static method on the idmclientwrapper
//   this is a capture request.
//
//   we pass in the authentication credentials, the actual globalservices wsdl url,
//        a timeout limit in millisecond,
//        and the request itself.
//
//   we expect back a profileresponse object.
 
try {
    system.out.println("global telephone lookup running ...");
    profileresponse profileresponse = idmclientwrapper
        .performcapturerequest(
            username,
            password,
            endpoint_url,
            timeout_ms,
            profilerequestcapture);
    system.out.println("... global telephone lookup has returned.");
 
    // disassemble the response to see what happened
    system.out.println("results from the global telephone lookup:");
    profileresponsedisassembler.disassemble(profileresponse);
} catch (exception e) {
    // in case something went wrong
    e.printstacktrace();
}
system.out.println("global telephone lookup complete.");

Multi-Threaded UK Address Postcode Lookup

This section illustrates how multiple requests may be processed in parallel. The example uses a helper class ExampleSimpleThreadPool, and the code to run the example is as follows:

// create a simple thread pool for this exercise
examplesimplethreadpool examplesimplethreadpool = new examplesimplethreadpool(
        username,
        password,
        endpoint_url,
        poolsize,
        numthreads);
 
// run the thread pool
system.out.println("postcode address lookup multi-threaded running ...");
 
examplesimplethreadpool.runpool();
 
system.out.println("... postcode address lookup multi-threaded has returned.");

ExampleSimpleThreadPool class

The simple thread pool uses the standard Java java.util.concurrent.ExecutorService to run the address lookup threads in parallel. The class has one main method, runPool().

//
//public method to start running the threads, and wait for them all to finish
//
public void runpool() {
    // create a standard java executorservice for running the threads
    executorservice executor = executors.newfixedthreadpool(poolsize);
 
    //create the individual threads, and add each one to the executor service
    for (int threadindex = 0; threadindex < numthreads; threadindex++) {
        // create individual instances of the credentials
        idmcredentials credentials = idmcredentials.createcredentials(username, password);
        // pick a postcode from the list
        int postcodeindex = threadindex % (postcodes.length);
        string postcode = postcodes[postcodeindex];
 
        // create the worker thread
        runnable worker = new exampleworkerthread(
                this.endpoint,
                credentials,
                postcode,
                threadindex);
        // ask the executor service to run it
        executor.execute(worker);
    }
 
    // close down the executor service (when it has finished) - we don't need it any more
    executor.shutdown();
    // ensure that it has finished before the java garbage disposal gets rid of it
    while (!executor.isterminated()) {
    }
    // done
    system.out.println("finished all threads");
}

The example selectes different postcodes from a list.

// list of postcodes to pick from
private static final string[] postcodes = {
        "sw1a 1aa", "eh6 6sb", "ng11 7ep", "tw9 1px", "ec2a 2gu", "g2 4jr", "l3 4ae", "ip5 3re"};

The address lookup is performed within the run() method of the ExampleWorkerThread class.

ExampleWorkerThread class

The ExampleWorkerThread class implements the standard Java Runnable interface. The main code is as follows:

public class exampleworkerthread implements runnable {
     ...
    @override
    //
    // implementation method for the runnable interface - this is called by the executorservice
    //
    public void run() {
        system.out.println(thread.currentthread().getname()+" start. index="+integer.tostring(this.threadindex)+", postcode = "+this.postcode);
        // process the request
        try {
            this.processrequest(this.threadindex);
        }
        catch(exception e) {
            system.err.println("exception caught in thread "+integer.tostring(this.threadindex)+"=> "+e.getmessage());
        }
        // back from processing
        system.out.println(thread.currentthread().getname()+" end. index="+integer.tostring(this.threadindex));
    }
 
    //
    // this method actually performs the address lookup
    // @param threadindex index of this thread
    //
    protected void processrequest(final int threadindex) {
        // create the request
        // first, we need a profilerequestcapture object to hold all the information
        profilerequestcapture profilerequestcapture = new profilerequestcapture();
 
        // within the profilerequestcapture, data is held in a profilerequestcapturedata object
        profilerequestcapturedata profilerequestcapturedata = new profilerequestcapturedata();
 
        // setup some basic options
        idmrequestoptions idmrequestoptions = exampleapplication.createidmrequestoptions();
        // put those options into the capture data
        profilerequestcapturedata.setoptions(idmrequestoptions);
 
        // for an address lookup, we need a search address object
        idmdatasearchaddress idmdatasearchaddress = new idmdatasearchaddress();
        // in this case, we just have the postcode
        idmdatasearchaddress.setpostcode(postcode);
        // put the address into the capture data
        profilerequestcapturedata.setaddress(idmdatasearchaddress);
 
        // now put the capture data into the overall request
        profilerequestcapture.setrequestdata(profilerequestcapturedata);
        // set the configuration id of the configuration we are licensed for (usually 1)
        profilerequestcapture.setconfigurationid(1);
        // set a descriptive reference
        profilerequestcapture.setcustomerreference("multithreaded sample: thread index="+integer.tostring(threadindex));
 
        // important: set the profile we are going to use - in this case for uk address web service
        profilerequestcapture.setprofileguid(exampleapplication.address_profile_guid);
 
 
 
        // now make the call using a static method on the idmclientwrapper
        //   this is a capture request.
        //
        //   we pass in the authentication credentials, the actual globalservices wsdl url,
        //        a timeout limit in millisecond,
        //        and the request itself.
        //
        //   we expect back a profileresponse object.
 
        try {
            system.out.println("postcode address lookup running for thread index="+integer.tostring(threadindex)+" ...");
            profileresponse profileresponse = idmclientwrapper
                    .performcapturerequest(
                            this.idmcredentials.getusername(),
                            this.idmcredentials.getpassword(),
                            this.endpoint,
                            timeout_ms,
                            profilerequestcapture);
            system.out.println("... postcode address lookup has returned for thread index="+integer.tostring(threadindex)+".");
 
            // disassemble the response to see what happened,
            system.out.println("results from the postcode address lookup for thread index="+integer.tostring(threadindex)+":");
            this.profileresponsedisassembler.disassemble(profileresponse);
        } catch (exception e) {
            e.printstacktrace();
        }
    }
}

Get started for free today

  • No credit card required
  • Cancel any time
  • 24/5 support
Get started