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

< Previous | Next >


Implement the component facade

In this step, you implement the code logic in the component facade for handling the ProcessTutorialStore requests, in addition to implementing the code for generating AcknowledgeTutorialStore responses.

The following diagram illustrates the major components that we will be modifying in this section of the tutorial and how they interact with one another during the process flow of a Get request:


Procedure

  1. Review the ProcessTutorialStoreCmdImpl.java class for handling Process requests:

    1. Open the SOITutorialStore-Server/ejbModule/com.mycompany.commerce.soitutorialstore.facade.server.commands/ProcessTutorialStoreCmdImpl.java class. This is the BOD command for the Process service.

    2. The method, performExpression(), is the callback method from the service controller upon receiving a Process service request.

  2. Import the remaining SOITutorialStore-Server code:

    1. Right-click the com.mycompany.commerce.soitutorialstore.facade.server.commands package.

    2. Select Import > File System and click Next.

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

    4. Select the following files:

      AcknowledgeTutorialStoreBuildCmdImpl.java

      Command to build the Acknowledge BOD after a process action.

      AcknowledgeTutorialStoreBuildErrorCmdImpl.java

      Command to build the Acknowledge BOD error response if the process action fails.

      AcknowledgeTutorialStoreBaseCmdImpl.java

      Base acknowledge class containing common methods.

    5. Click Finish. Click Yes to All to overwrite any existing files.

  3. Update the SOITutorialStore-Server build path:

    1. Right-click the SOITutorialStore-Server project and select Properties.

    2. Select Java Build Path.

    3. Include the WebSphereCommerceServerExtensionsData project in the build path to resolve the compilation error.

  4. Update the SOITutorialStore-Server Java EE module dependencies:

    1. Right-click the SOITutorialStore-Server project and select Properties.

    2. Select Java EE Module Dependencies.

    3. Select the SOITutorialStore-Client.jar and SOITutorialStore-DataObject.jar projects and click OK.

  5. Organize the imports for the SOITutorialStore-Server project:

    1. Open the Java perspective in WebSphere Commerce Developer.

    2. Right-click the SOITutorialStore-Server\EJBModule folder and select Source.

    3. Select Organize Imports.

    4. Save the file.

  6. Prepare the SOITutorialStore-Server project for deployment:

    1. Open the Java perspective in WebSphere Commerce Developer.

    2. Right-click the SOITutorialStore-Server project and select Java EE > Prepare for Deployment.

  7. Register the Process command by running the following SQL statements.

    1. delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ProcessTutorialStoreCmd';

    2. insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME, TARGET) VALUES (0, 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ProcessTutorialStoreCmd', 'com.ibm.commerce.foundation.server.command.soi.MessageMappingCmdImpl', 'Local');

  8. Configure message mapping to link the Process Open and Close actions to the WebSphere Commerce StoreOpenCmd and StoreCloseCmd commands:

    1. Open the WC_EAR/xml/messaging/component-services/component-services-user-template.xml file.

    2. Paste the following code within the <ECTemplate> tag:

      <!-- TutorialStore -->
      <TemplateDocument>
      <DocumentType version="*">ProcessTutorialStore</DocumentType>
      <StartElement>ProcessTutorialStore</StartElement>
      <TemplateTagName>ProcessTutorialStoreMap</TemplateTagName>
      <CommandMapping>
      <Command CommandName="com.ibm.commerce.store.commands.StoreOpenCmd" Condition='actionCode="Open" AND actionExpression="/TutorialStore"'>
      <Constant Field="URL">NoURL</Constant>
      <Constant FieldInfo='CONTROL' Field='responseCommand'>com.mycompany.commerce.soitutorialstore.facade.server.commands.AcknowledgeTutorialStoreBuildCmdImpl</Constant>
      <Constant FieldInfo='CONTROL' Field='errorCommand'>com.mycompany.commerce.soitutorialstore.facade.server.commands.AcknowledgeTutorialStoreBuildErrorCmdImpl</Constant>
      </Command>
      <Command CommandName="com.ibm.commerce.store.commands.StoreCloseCmd" Condition='actionCode="Close" AND actionExpression="/TutorialStore"'>
      <Constant Field="URL">NoURL</Constant> 
      <Constant FieldInfo='CONTROL' Field='responseCommand'>com.mycompany.commerce.soitutorialstore.facade.server.commands.AcknowledgeTutorialStoreBuildCmdImpl</Constant>
      <Constant FieldInfo='CONTROL' Field='errorCommand'>com.mycompany.commerce.soitutorialstore.facade.server.commands.AcknowledgeTutorialStoreBuildErrorCmdImpl</Constant>
      </Command> 
      </CommandMapping>
      </TemplateDocument>
      
      <TemplateTag name="ProcessTutorialStoreMap">
      <Tag XPath="ApplicationArea/BusinessContext/ContextData" XPathType="USERDATA"/>
      <Tag XPath="DataArea/Process/ActionCriteria/ActionExpression@actionCode" Field="actionCode" FieldInfo="COMMAND"/>
      <Tag XPath="DataArea/Process/ActionCriteria/ActionExpression" Field="actionExpression" FieldInfo="COMMAND"/>
      <Tag XPath="DataArea/TutorialStore/StoreIdentifier/UniqueID" Field="targetStoreId"/>
      </TemplateTag>
      

< Previous | Next >


+

Search Tips   |   Advanced Search