Implementing the client library

The primary purpose of the client library is to simplify and eliminate code on the client. The client library is essentially a Java layer to help Java applications integrate with your service architecture, with no additional code generation required. The client library already has support for session and authentication and provides Java-based clients a standardized mechanism to create the logical SDO objects to represent service requests.

About this task

Each service module provides a client library project to access the services provided by the module. The client project contains the following assets:
  • Interfaces of the service provided for each noun
  • A file that contains constants that can be shared between client and server
  • A client package that contains
    • The abstract client Java class that contains common methods and methods required
    • A programming friendly web enabled Java class that extends from the abstract class to implement the Java friendly and web enabled methods
    • Noun-specific exceptions to represent client errors and server errors

This lesson of the tutorial demonstrates how to add convenience methods that hide the complexity of creating the different GetProject, ChangeProject, and ProcessProject requests.

Procedure

  1. Import the provided ProjectFacadeConstants class:
    1. In the Enterprise Explorer view, expand Project-Client/src.
    2. Right-click com.mycompany.commerce.project.facade; click Import.
    3. Expand General select File System, then click Next.
    4. Browse to the temporary location where you unzipped RecipeServices.zip.
    5. Browse to the com.mycompany.commerce.project.facade folder; select the folder, then click Ok.
    6. Select ProjectFacadeConstants.java; click Finish.
    7. Click Yes to overwrite the existing file.
  2. Import the provided ProjectFacadeClient.java class that contains the Java friendly client methods:
    1. Expand Project-Client/src.
    2. Right-click com.mycompany.commerce.project.facade.client; click Import.
    3. Expand General; select File System, then click Next.
    4. Browse to the temporary location where you unzipped RecipeServices.zip.
    5. Browse to the com.mycompany.commerce.project.facade.client folder; select the folder, then click Ok.
    6. Select ProjectFacadeClient.java; click Finish.
    7. Click Yes to overwrite the existing file.
  3. Organize the imports for the Project-Client project:
    1. Open the Java perspective in WebSphere Commerce Developer.
    2. Expand Project-Client.
    3. Right-click the src folder; select Source.
    4. Click Organize Imports.