Tutorials > Program model > Web services > Create a WebSphere Commerce service module (SOI) > Creating the Process TutorialStore service

< Previous | Next >


Implement the client library

In this step, you add convenience methods that hide the complexity of creating the different GetTutorialStore requests.


Procedure

  1. Open the SOITutorialStore-Client/src/com.mycompany.commerce.soitutorialstore.facade.SOITutorialStoreFacadeConstants class.

  2. Add the following constants to represent the open store and close store process actions.

    /**
    * The Open Store process action.
    */
    public static String PROCESS_ACTION_OPEN = "Open";
    
    /**
    * The Close Store process action.
    */
    public static String PROCESS_ACTION_CLOSE = "Close";
    

  3. Save the SOITutorialStoreFacadeConstants class.

  4. Open the com.mycompany.commerce.soitutorialstore.facade.client.SOITutorialStoreFacadeClient class.

  5. Add the following client methods that build the appropriate BOD:

    /**
    * This method composes a Process BOD with an Action of 'Close' and sends
    * the BOD to the TutorialStore-Server.
    */
    public AcknowledgeTutorialStoreDataAreaType closeStore(String storeId) {
    final String METHODNAME = "closeStore(String storeId)";
    
    ProcessTutorialStoreType processTutorialStore = getSOITutorialStoreFactory()
    .createProcessTutorialStoreType();
    ProcessTutorialStoreDataAreaType dataArea = getSOITutorialStoreFactory()
    .createProcessTutorialStoreDataAreaType();
    processTutorialStore.setDataArea(dataArea);
    
    java.util.List expressions = new ArrayList();
    expressions.add(createActionExpression(
    SOITutorialStoreFacadeConstants.PROCESS_ACTION_CLOSE, SelectionCriteriaHelper.STR_XPATH_LANG, SOITutorialStoreFacadeConstants.XPATH_STORE));
    dataArea.setProcess(createProcessVerb(expressions));
    
    StoreIdentifierType storeIdentifier = CommerceFoundationFactory.eINSTANCE
    .createStoreIdentifierType();
    storeIdentifier.setUniqueID(storeId);
    
    TutorialStoreType tutorialStore = getSOITutorialStoreFactory()
    .createTutorialStoreType();
    tutorialStore.setStoreIdentifier(storeIdentifier);
    dataArea.getTutorialStore().add(tutorialStore);
    
    AcknowledgeTutorialStoreDataAreaType acknowledgeTutorialStoreDataArea = processTutorialStore(
    processTutorialStore).getDataArea();
    
    return acknowledgeTutorialStoreDataArea;
    }
    
    /**
    * This method composes a Process BOD with an Action of 'Open' and sends the
    * BOD to the TutorialStore-Server.
    */
    public AcknowledgeTutorialStoreDataAreaType openStore(String storeId) {
    final String METHODNAME = "openStore(String storeId)";
    
    ProcessTutorialStoreType processStore = getSOITutorialStoreFactory()
    .createProcessTutorialStoreType();
    ProcessTutorialStoreDataAreaType dataArea = getSOITutorialStoreFactory()
    .createProcessTutorialStoreDataAreaType();
    processStore.setDataArea(dataArea);
    
    java.util.List expressions = new ArrayList();
    expressions.add(createActionExpression(
    SOITutorialStoreFacadeConstants.PROCESS_ACTION_OPEN, SelectionCriteriaHelper.STR_XPATH_LANG, SOITutorialStoreFacadeConstants.XPATH_STORE));
    dataArea.setProcess(createProcessVerb(expressions));
    
    StoreIdentifierType storeIdentifier = CommerceFoundationFactory.eINSTANCE
    .createStoreIdentifierType();
    storeIdentifier.setUniqueID(storeId);
    
    TutorialStoreType tutorialStore = getSOITutorialStoreFactory()
    .createTutorialStoreType();
    tutorialStore.setStoreIdentifier(storeIdentifier);
    dataArea.getTutorialStore().add(tutorialStore);
    
    AcknowledgeTutorialStoreDataAreaType acknowledgeStoreDataArea = processTutorialStore(
    processStore).getDataArea();
    
    return acknowledgeStoreDataArea;
    }
    

  6. Save the SOITutorialStoreFacadeClient class.

  7. Organize the imports for the SOITutorialStore-Client project:

    1. Open the Java perspective in WebSphere Commerce Developer.

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

    3. Select Organize Imports.

< Previous | Next >


+

Search Tips   |   Advanced Search