Tutorials > Program model > Web services > Create a new WebSphere Commerce BOD service module

< Previous | Next >


Implement the client library

The client library's primary purpose is to simplify and eliminate code on the client. The client library is essentially a Java layer to help Java applications integrate with the 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.

Each service module should provide a client library project to access the services provided by the module. The client project contains the following:

The following diagram shows the client library in the context of the overall customization process:

This lesson of the tutorial shows you how to add convenience methods that hide the complexity of creating the different GetBODTutorialStore, ChangeBODTutorialStore and ProcessBODTutorialStore requests.


Procedure

  1. Open the com.mycompany.commerce.bodtutorialstore.facade.BODTutorialStoreFacadeConstants class in the BODTutorialStore-Client project.

  2. Add the constants that represent actions supported by the store, supported XPath expressions and access profiles.

    // ==========================================
    // The following is a predefined set of access profiles provided by the component.
    // ==========================================
    /**
    * This constants represents an access profile that returns detail
    * information about the noun. This includes most of the
    * information associated with the specified noun.
    */
    public static final String ACCESS_PROFILE_DETAIL_INFORMATION = "MyCompany_Details";
    
    // =====================================================
    // The following is a list of actions that can be used for the process request.
    // =====================================================
    
    /**
    * The Open Store process action.
    */
    public static String PROCESS_ACTION_OPEN = "Open";
    
    /**
    * The Close Store process action.
    */
    public static String PROCESS_ACTION_CLOSE = "Close";
    
    // ============================================================
    // The following is the change actions and XPath keys.
    // ============================================================
    /**
    * The Change action to update a store.
    */
    public static String CHANGE_ACTION_UPDATE = "Change";
    
    /**
    * The XPath key to update the store state.
    */
    public static String XPATH_STORE = "/TutorialStore[{0}]";
    
    /**
    * The XPath key to update the store description.
    */
    public static String XPATH_DESCRIPTION = "/TutorialStore[{0}]/StoreDescription";
    
    // ===================================================================
    // The following is a list of Get expression XPath keys. 
    // ============================================================
    
    /**
    * The XPath key for finding all stores.
    */
    public static String ALLEXPRESSION = "/TutorialStore";
    
    /** 
    * The XPath key for finding a store by ID.
    */
    public static String IDEXPRESSION = "/TutorialStore[StoreIdentifier[(UniqueID={0})]]";
    
    /**
    * The XPath key for finding a store by name.
    */
    public static String NAMEEXPRESSION = "/TutorialStore[StoreIdentifier[ExternalIdentifier[(NameIdentifier=\"{0}\")]]]";
    

  3. Import the provided BODTutorialStoreFacadeClient class containing the Java friendly client methods:

    1. In the Enterprise Explorer view, right-click the BODTutorialStore-Client/src/com.mycompany.commerce.bodtutorialstore.facade.client package.

    2. Select Import > FileSystem. Click Next.

    3. Browse to the temporary location where you unzipped TutorialStore.zip.

    4. Browse to the BODTutorialStore-Client\src\com.mycompany.commerce.bodtutorialstore.facade.client folder.

    5. Select BODTutorialStoreFacadeClient.java Click Finish.

    6. Click Yes to All to overwrite the existing file.

  4. Organize the imports for the BODTutorialStore-Client project:

    1. Open the Java perspective in WebSphere Commerce Developer.

    2. Right-click the BODTutorialStore-Client\src folder and select Source.

    3. Select Organize Imports.

< Previous | Next >


+

Search Tips   |   Advanced Search