Using a client library

A client library is used to create a web service request to HCL Commerce. You can use an HCL Commerce services client library (for example, MemberFacadeClient) in a standard Java application.

Before you begin

About this task

A client library's use depends on how it is invoked:
  • Using the GetData tag to perform a service request; for example, creating a Get request by using a JSP, applicable to Management Center and Store clients.
  • Using the ComponentServiceAction; for example, creating a Change/Process request from the Store.
  • Directly using the client library; for example, a J2SE application.

To use a client library:


  1. Add the client library JAR file path to the build path of your Java application.
  2. Initialize the client library, as seen in the following code sample:
    private  MemberFacadeClient iClient = null;
     * Sets the initializes the client based on the <code>CallbackHandler</code>
     * @param aCallbackHandler {@link CallbackHandler}
    private void initializeClient(CallbackHandler aCallbackHandler) {
      iClient = new MemberFacadeClient(iBusinessContext, aCallbackHandler);
  3. Use the client library, as seen in the following code sample for a Get service call:
    //Initialize the client with site admin user permissions
    initializeClient(new SampleCallbackHandlerImpl(SITE_ADMIN_LOGON_ID, SITE_ADMIN_PWD));
    //Create the BOD                
    GetType getType = AbstractBusinessObjectDocumentFacadeClient.createGetVerb(
      "{" + MemberFacadeConstants.SELF + "=true;" + SelectionCriteriaHelper.STR_ACCESS_PROFILE_PARAMETER 
      + "=" + MemberFacadeConstants.ACCESS_PROFILE_SUMMARY_INFORMATION + "}/Person");
    //Use the client library to call the Get Person Web service
    ShowPersonDataAreaType showPersonDAT = iClient.getPerson(getType);
    // Get the PersonType from the response and use the printPerson() method to display the response data
    PersonType person = (PersonType) showPersonDAT.getPerson().get(0);
    // Output the logon ID
    An example for calling a Process or Change service is seen in the following code sample:
    //Initialize the client to run as a guest user - use null as the
    callback handler
    Map parameters = new HashMap();
    parameters.put("logonId", new String[]{ "myLogonId" } );
    parameters.put("logonPassword", new String[]{ "myPassw0rd" });
    parameters.put("lastName", new String[]{"myLastName"});
    parameters.put("city",        new String[]{"Toronto"});
            Map result = iClient.registerPerson(parameters);
            String [] strUserId = (String[]) result.get("userId");
            System.out.println("========= New userId: " +
    } catch (PersonException e) {
            List listErrors = e.getClientErrors();
            if (listErrors != null) {
                    for (int i=0; i < listErrors.size(); i++) {
                            ClientError clientError = (ClientError)
                            System.out.println("Message: " +
                            System.out.println("Error key: " +
                            System.out.println("Error code: " +
  4. Process the response as appropriate for your Java application.