Tutorials > Program model > Web services > Create a WebSphere Commerce service module (SOI) > Creating the Process TutorialStore service
Implement the client library
In this step, you add convenience methods that hide the complexity of creating the different GetTutorialStore requests.
Procedure
- Open the SOITutorialStore-Client/src/com.mycompany.commerce.soitutorialstore.facade.SOITutorialStoreFacadeConstants class.
- 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";
- Save the SOITutorialStoreFacadeConstants class.
- Open the com.mycompany.commerce.soitutorialstore.facade.client.SOITutorialStoreFacadeClient class.
- 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; }
- Save the SOITutorialStoreFacadeClient class.
- Organize the imports for the SOITutorialStore-Client project:
- Open the Java perspective in WebSphere Commerce Developer.
- Right-click the SOITutorialStore-Client\src folder and select Source.
- Select Organize Imports.