Wednesday, August 13, 2014

Webservice in WCS V7 SOI Based






In this step, you are going to use the Java Emitter Template (JET) to generate the base code for your TutorialStore component. A significant amount of Java code is related to the processing of WebSphere Commerce nouns and can be abstracted and generated. This allows you to focus on implementing the code specific to each component, for example the component's nouns and the noun's business logic.
Procedure
2.    Open the Java EE perspective.
3.    Create the application definition file to create the base code for the TutorialStore SOI service module.
a.    Create the service module input file.
                                      i.        Right-click on the WebSphereCommerceServerExtensionsLogic project and select New > Folder.
                                     ii.        Enter ServiceModuleDefinition as the folder name. This creates a single location to store all service module input files.
                                    iii.        Right-click the ServiceModuleDefinition folder and select New > File.
                                   iv.        Enter SOITutorialStore.xml as the filename and click Finish.
b.    Paste the following application definition into the file:
<_pattern:commerceComponent
xmlns:_pattern="http://www.ibm.com/xmlns/prod/commerce/foundation/pattern" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/pattern ../../WC/xml/config/xsd/wc-component-patten.xsd "name="SOITutorialStore" packagenameprefix="com.mycompany.commerce" company="MyCompany" namespace="http://www.mycompany.com/xmlns/prod/commerce/9/soitutorialstore" nlsprefix="myco" type="SOI"> <_pattern:noun name="TutorialStore" get="true" process="true" change="false" sync="false"/>
</_pattern:commerceComponent>
Note: The definition indicates the name of the noun (TutorialStore) and the verbs that are enabled for the pattern. This file determines the assets and code to be generated for you.
c.    Save and close the file.

4.    Right-click SOITutorialStore.xml and select Run As > Input for JET Transformation:
5.    In the Transformation section:
a.    Select the following ID:
§  com.ibm.commerce.toolkit.internal.pattern.componentprojects
                Click OK.
                The pattern is applied. Verify that the following projects are created, by switching to the Navigator view:
o    SOITutorialStore-Client
o    SOITutorialStore-DataObjects
o    SOITutorialStore-Server
o    SOITutorialStore-UnitTests
o    SOITutorialStoreServicesHTTPInterface
o    SOITutorialStoreServicesJMSInterface
                Add the service module to the WebSphere Commerce application to update the build dependencies for the service module. Build dependencies are managed using the Java EE Module dependencies instead of the project classpath.
 .     Switch to the Java EE perspective and expand the WC project.
a.    Double-click WebSphereCommerceServer.
b.    Select the Design tab.
c.    Click Add. If Add cannot be selected, click Application, then click Add.
d.    Select Module and click OK.
e.    Select SOITutorialStore-Server and click Finish.
f.     Click Add.
g.    Select Module and click OK.
h.    Select SOITutorialStoreServicesHTTPInterface and click Finish.
i.      In the Application Deployment Descriptor Editor, under Actions, click Manage Utility Jars. If Manage Utility Jars does not appear close then reopen WebSphereCommerceServer.
j.     Ensure the following values are selected
§  SOITutorialStore-Client
§  SOITutorialStore-DataObjects
k.    Click OK.
l.      Save the deployment descriptor.
                Right-click the SOITutorialStore-Server project and select Properties.
                Select Java EE Module Dependencies.
                Ensure the following are selected:
o    Enablement-RelationshipManagementData.jar from the WC project.
o    Enablement-RelationshipManagementLogic.jar from the WC project.
o    SOITutorialStore-Client from the SOITutorialStore-Client project.
o    SOITutorialStore-DataObjects from the SOITutorialStore-DataObjects project.
                Click OK.
Note: Build errors will show up in the projects at this stage because the TutorialStore data objects have not yet been generated from the TutorialStore noun. You can ignore these build errors for now and continue with the tutorial. Once the data objects are generated in the next steps of the tutorial, these compilation errors will be resolved.



In this step, you generate the data objects required for implementing the logical data model of your TutorialStore noun, which is defined in the TutorialStore.xsd file.
Before generating the data objects, you need to set up the predefined WebSphere Commerce type constructs, and to update the JET-generated TutorialStore.xsd template with your own noun definition.
After you have updated the XSD definition file, your projects can generate the data objects for your TutorialStore noun. In Java, the data objects representing the TutorialStore noun are service data objects (SDOs) and are stored in the TutorialStore-DataObjects project. These data objects are generated directly from the TutorialStore noun using the Eclipse Modeling Framework (EMF).

Remember: You must have the Eclipse Modelling Framework (EMF) capability enabled in WebSphere Commerce Developer to complete this step of the tutorial.
Procedure
1.    Setup the predefined WebSphere Commerce type constructs, and update the JET-generated TutorialStore.xsd template with your own noun definition:
a.    In the Enterprise Explorer view, go to SOITutorialStore-DataObjects/xsd/OAGIS/9.0/Overlays/MyCompany/Commerce/Resources/Nouns.
b.    Open the SOITutorialStore.xsd file for editing.
c.    Replace the generated content with the contents of TutorialStore.xsd. The file can be found in the TutorialStore.zip file, downloaded from the tutorial's prerequisites section.
d.    Save and close the file.
Note: You can ignore the validation error messages at this time. These errors will be resolved later in the tutorial.
2.    Generate the data objects for your TutorialStore noun:
a.    Open the SOITutorialStore-DataObjects\ecore folder.
b.    Right-click SOITutorialStore.genmodel and select Reload.
c.    Select XML Schema and click Next.
d.    Click Next again and click Finish.
e.    Open SOITutorialStore.genmodel.
f.     Right-click the SOITutorialStore element under the SOITutorialStore root and select Generate Model Code. This generates the SOITutorialStore-DataObjects code.
g.    Verify that the SOITutorialStore-DataObjects project has no compilation errors.


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.
Procedure
1.    Review the ProcessTutorialStoreCmdImpl.java class for handling Process requests:
a.    Open the SOITutorialStore-Server/ejbModule/com.mycompany.commerce.soitutorialstore.facade.server.commands/ProcessTutorialStoreCmdImpl.java class. This is the BOD command for the Process service.
b.    The method, performAction(), is the callback method from the service controller upon receiving a Process service request.
2.    Import the remaining SOITutorialStore-Server code:
a.    Right-click the com.mycompany.commerce.soitutorialstore.facade.server.commands package.
b.    Select Import > General > File System and click Next.
c.    Browse to the temporary location where you unzipped TutorialStore.zip.
d.    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.
e.    Click Finish. Click Yes to All to overwrite any existing files.
3.    Update the SOITutorialStore-Server build path:
a.    Right-click the SOITutorialStore-Server project and select Properties.
b.    Select Java Build Path.
c.    Click the Projects tab; Click Add.
d.    Select the WebSphereCommerceServerExtensionsData project to add to the build path to resolve the compilation error.
4.    Update the SOITutorialStore-Server Java EE module dependencies:
a.    Right-click the SOITutorialStore-Server project and select Properties.
b.    Select Java EE Module Dependencies.
c.    Select the SOITutorialStore-Client.jar and SOITutorialStore-DataObject.jar projects and click OK.
5.    Organize the imports for the SOITutorialStore-Server project:
a.    Open the Java perspective in WebSphere Commerce Developer.
b.    Expand SOITutorialStore-Server; right-click the EJBModule folder.
c.    Select Source > Organize Imports.
6.    Prepare the SOITutorialStore-Server project for deployment:
a.    Open the Java perspective in WebSphere Commerce Developer.
b.    Delete any file that does not begin with SOI in the com.mycompany.commerce.soitutorialstore.facade.server package before executing Prepare for Deployment.
c.    Right-click the SOITutorialStore-Server project and select Java EE > Prepare for Deployment.
7.    Register the Process command by running the following SQL statements.
8.  delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ProcessTutorialStoreCmd';
9.   
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');
10. Configure message mapping to link the Process Open and Close actions to the WebSphere Commerce StoreOpenCmd and StoreCloseCmd commands:
a.    Open the WC_eardir/xml/messaging/component-services/component-services-user-template.xml file.
b.    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>
c.    Save your changes and close the file.



In this step, you add convenience methods that hide the complexity of creating the different ProcessTutorialStore requests.
Procedure
1.    In the Enterprise Explorer view, Go to SOITutorialStore-Client/src/com.mycompany.commerce.soitutorialstore.facade
2.    Open the SOITutorialStoreFacadeConstants class for editing.
3.    Add the following constants to represent the open store and close store process actions.

/**
* The XPath key for the TutorialStore.
*/
 public static final String XPATH_STORE = "/TutorialStore";
 
/**
* The XPath key for finding a store by ID.
*/
 public static final String IDEXPRESSION = "/TutorialStore/TutorialStoreIdentifier[(UniqueID={0})]";
 
/**
* The store ID.
*/
 public static final String STORE_ID = "storeId"; 

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

/**
* The Close Store process action.
*/
public static final String PROCESS_ACTION_CLOSE = "Close";
4.    Save your changes and close the file.
5.    Go to com.mycompany.commerce.soitutorialstore.facade.client.
6.    Open the SOITutorialStoreFacadeClient class for editing.
7.    Add the following client methods that build the appropriate BOD:
8.   
/**
 * This method composes a Get BOD with an expression to find a store by ID
 * and sends the BOD to the TutorialStore-Server.
 * @throws TutorialStoreException 
 */
public ShowTutorialStoreDataAreaType findStoreById(String[] storeId,
    String accessProfile) throws TutorialStoreException {
  final String METHODNAME = "findStoreById";
  if(LoggingHelper.isEntryExitTraceEnabled(LOGGER)){
    LOGGER.entering(CLASSNAME, METHODNAME);
  }
 
  // Build the expression.
  String expression = java.text.MessageFormat.format(
    SOITutorialStoreFacadeConstants.IDEXPRESSION, storeId);
  SelectionCriteriaHelper selectionCriteriaHelper = new SelectionCriteriaHelper(
    expression);
  selectionCriteriaHelper.addAccessProfile(accessProfile);
  ExpressionType queryExpression = selectionCriteriaHelper
    .getSelectionCriteriaExpression();
 
  // Create the request message.
  GetType verb = createGetVerb(queryExpression);
 
  // Perform the request.
  ShowTutorialStoreDataAreaType showTutorialStoreDataArea = getTutorialStore(verb);
  
  if(LoggingHelper.isEntryExitTraceEnabled(LOGGER)){
    LOGGER.exiting(CLASSNAME, METHODNAME);
  }
            return showTutorialStoreDataArea;
}
 
/**
 * This method composes a Get BOD with an expression to find all the stores
 * and sends the BOD to the TutorialStore-Server.
 */
public ShowTutorialStoreDataAreaType findAllStores() {
  final String METHODNAME = "findAllStores";
  if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)){
    LOGGER.entering(CLASSNAME, METHODNAME);
  }
 
  // Build the expression.
  SelectionCriteriaHelper selectionCriteriaHelper = new SelectionCriteriaHelper(
    SOITutorialStoreFacadeConstants.XPATH_STORE);
  selectionCriteriaHelper
    .addAccessProfile(SOITutorialStoreFacadeConstants.ACCESS_PROFILE_SUMMARY_INFORMATION);
  ExpressionType queryExpression = selectionCriteriaHelper
    .getSelectionCriteriaExpression();
 
  // Create the request message.
  GetType verb = createGetVerb(queryExpression);
 
  // Send the request.
  ShowTutorialStoreDataAreaType showTutorialStoreDataArea = getTutorialStore(verb);
 
  if(LoggingHelper.isEntryExitTraceEnabled(LOGGER)){
    LOGGER.exiting(CLASSNAME, METHODNAME);
  }
  return showTutorialStoreDataArea;
 
     }


/**
 * 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;
}
9.    Save your changes and close the file.
10. Organize the imports for the SOITutorialStore-Client project:
a.    Open the Java perspective in WebSphere Commerce Developer.
b.    Right-click the SOITutorialStore-Client\src folder.
c.    Select Source > Organize Imports.



In this step, you are going to use the generated JUnit test class, TutorialStoreFacadeClientTest, to validate your TutorialStore service module.
Procedure
1.    Update the JUnit test client:
a.    Open the SOITutorialStore-UnitTests/src/com.mycompany.commerce.soitutorialstore.facade.SOITutorialStoreFacadeClientTest class.
b.    Replace the methods testGetTutorialStore() and testTutorialStore() with the following JUnit test methods. Replace user and password with your WebSphere Commerce administrator ID and password. This method assumes that a WebSphere Commerce store with storeID of 10001 exists and is currently open. If this is not the case, replace "10001" with your WebSphere Commerce storeID.
public void testGetTutorialStore() {

 // Create the query expression using an XPath statement and access
 // profile.
 String storeID = "10001";

 SelectionCriteriaHelper selectionCriteriaHelper = new SelectionCriteriaHelper(
 "/TutorialStore/TutorialStoreIdentifier[(UniqueID=" + storeID
 + ")]");
 selectionCriteriaHelper.addAccessProfile("MyCompany_Summary");
 ExpressionType queryExpression = selectionCriteriaHelper
 .getSelectionCriteriaExpression();

 // Create the Get BOD from query expression and send it to the server.
 try {
  ShowTutorialStoreDataAreaType result = iClient
  .getTutorialStore(iClient.createGetVerb(queryExpression));
  TutorialStoreType tutorialStore = (TutorialStoreType) result
  .getTutorialStore().get(0);
  assertEquals(storeID, tutorialStore.getStoreIdentifier()
  .getUniqueID());
 } catch (TutorialStoreException e) {
 
 } catch (Exception e) {

}
}
      public void testTutorialStore() {

 String[] storeID = { "10001" };
 BusinessContextType businessContext = CommerceFoundationFactory.eINSTANCE
 .createBusinessContextType();

      // Change username and password to match the server.
 javax.security.auth.callback.CallbackHandler callbackHandler = new SampleCallbackHandlerImpl(
 "user", "password");

 // Create the client facade.
 SOITutorialStoreFacadeClient client = new SOITutorialStoreFacadeClient(
 businessContext, callbackHandler);

      // Verify that the store is open.
 try {
  ShowTutorialStoreDataAreaType result = client
  .findStoreById(
  storeID,
  SOITutorialStoreFacadeConstants.ACCESS_PROFILE_DETAILS_INFORMATION);
  TutorialStoreType tutorialStore = (TutorialStoreType) result
  .getTutorialStore().get(0);
  assertEquals("Open", tutorialStore.getStoreState().getName());
 } catch (TutorialStoreException tse) {

  } catch (Exception e) {
 
 }
}
c.    Replace the method testProcessTutorialStore() with the following JUnit test method:
public void testProcessTutorialStore() {

 String[] storeID = { "10001" };
 SOITutorialStoreFactory iFactory = SOITutorialStoreFactory.eINSTANCE;

 // Construct the request BOD.
 ProcessTutorialStoreType processTutorialStore = iFactory
 .createProcessTutorialStoreType();
 processTutorialStore.setDataArea(iFactory
 .createProcessTutorialStoreDataAreaType());

 // Construct the TutorialStore noun and add it to the request.
 java.util.List TutorialStoreList = processTutorialStore.getDataArea()
 .getTutorialStore();
 TutorialStoreType tutorialstore = iFactory.createTutorialStoreType();
 StoreIdentifierType storeIdentifier = CommerceFoundationFactory.eINSTANCE
 .createStoreIdentifierType();
 storeIdentifier.setUniqueID(storeID[0]);
 tutorialstore.setStoreIdentifier(storeIdentifier);
 TutorialStoreList.add(tutorialstore);

 try {
  // Verify that the store is open.
  ShowTutorialStoreDataAreaType result = iClient
  .findStoreById(
   storeID,
   SOITutorialStoreFacadeConstants.ACCESS_PROFILE_DETAILS_INFORMATION);
  TutorialStoreType tutorialStore = (TutorialStoreType) result
  .getTutorialStore().get(0);
  assertEquals(StoreStateType.OPEN, tutorialStore.getStoreState()
  .getValue());

 // Construct the open action expression.
 java.util.List actions = new java.util.ArrayList();
 actions.add(AbstractBusinessObjectDocumentFacadeClient
 .createActionExpression(
 SOITutorialStoreFacadeConstants.PROCESS_ACTION_CLOSE,
 SelectionCriteriaHelper.STR_XPATH_LANG,
 SOITutorialStoreFacadeConstants.XPATH_STORE));
 com.ibm.commerce.oagis9.datatypes.ProcessType processVerb = AbstractBusinessObjectDocumentFacadeClient
 .createProcessVerb(actions);
 processTutorialStore.getDataArea().setProcess(processVerb);

 // send the request BOD and get back the response
 AcknowledgeTutorialStoreType acknowledgeTutorialStore = iClient
 .processTutorialStore(processTutorialStore);

 // Pause while the store registry refreshes.
 try {
  Thread.sleep(5000);
 } catch (Exception e) {
  e.printStackTrace();
 }

 // Verify that the store is closed.
 result = iClient
 .findStoreById(
  storeID,
  SOITutorialStoreFacadeConstants.ACCESS_PROFILE_DETAILS_INFORMATION);
  tutorialStore = (TutorialStoreType) result.getTutorialStore().get(0);
  assertEquals(StoreStateType.CLOSED, tutorialStore.getStoreState()
  .getValue());

 // Construct the close action expression.
 actions.clear();
 actions.add(AbstractBusinessObjectDocumentFacadeClient
 .createActionExpression(
 SOITutorialStoreFacadeConstants.PROCESS_ACTION_OPEN,
 SelectionCriteriaHelper.STR_XPATH_LANG,
 SOITutorialStoreFacadeConstants.XPATH_STORE));
 processVerb = AbstractBusinessObjectDocumentFacadeClient
 .createProcessVerb(actions);
 processTutorialStore.getDataArea().setProcess(processVerb);

 // send the request BOD and get back the response
 acknowledgeTutorialStore = iClient
 .processTutorialStore(processTutorialStore);

 // Pause while the store registry refreshes.
 try {
  Thread.sleep(5000);
 } catch (Exception e) {
  e.printStackTrace();
 }

 // Verify that the store is open.
 result = iClient
 .findStoreById(
  storeID,
  SOITutorialStoreFacadeConstants.ACCESS_PROFILE_DETAILS_INFORMATION);
  tutorialStore = (TutorialStoreType) result.getTutorialStore().get(0);
  assertEquals(StoreStateType.OPEN, tutorialStore.getStoreState()
  .getValue());
 } catch (TutorialStoreException tse) {

} catch (Exception e) {
 
 }
}
d.    Save your changes and close the file.
2.    Organize the imports for the SOITutorialStore-UnitTests project:
a.    Open the Java perspective in WebSphere Commerce Developer.
b.    Right-click the SOITutorialStore-UnitTests\src folder.
c.    Select Source > Organize Imports.
3.    Start the test server: On the Server page, right-click the WebSphere Commerce Test Server and select Start.
4.    If the WC project is not already published to the WebSphere Commerce Test Server, publish the WebSphere Commerce project:
a.    On the Server page, right-click the WebSphere Commerce Test Server and select Add and Remove Projects.
b.    Select the WC project.
c.    Click Add and click Finish.
If the WC project is already published, right-click the WebSphere Commerce Test Server and select Publish.
5.    Set up a TCP/IP monitor in WebSphere Commerce Developer. You will use this TCP/IP monitor to observe the request and response documents going to and from the WebSphere Commerce service you created. To create a TCP/IP Monitor to forward requests to WebSphere Commerce:
a.    Select Window > Preferences.
b.    From the Preferences panel select Run/Debug > TCP/IP Monitor.
c.    Click Add.
d.    Type the following information:
§  Local monitoring port: 81.
§  Hostname: The hostname of the WebSphere Commerce Server where the SOITutorialStore service is running.
§  Port: 80 for WebSphere Commerce Developer, 8007 for production.
e.    Click OK.
f.     Select the created TCP/IP monitor.
g.    Click Start.
h.    Click OK.
6.    Configure the TutorialStore Unit Test to use the TCP/IP monitor:
a.    Go to SOITutorialStore-UnitTests\src\config\com.mycompany.commerce.soitutorialstore
b.    Open wc-component-client.xml in a text editor.
c.    Change the value of the url property from localhost:8007 to localhost:81.
d.    Save the file.
7.    Run the JUnit test:
a.    Go to SOITutorialStore-UnitTests/src/com.mycompany.commerce.soitutorialstore.facade
b.    Right-click the SOITutorialStoreFacadeClientTest.java class and select Run as > JUnit Test. You should see the request and response XML documents transmitted between the client and server on the TCP/IP monitor.
c.    If the validation is successful, a green bar is displayed on the JUnit view.
8.    From the TCP/IP Monitor, you can review the Get message sent by the client library, and the Show response replied by the component facade.
The following BODs are present:
o    Process BOD.
o    Acknowledge BOD.

No comments:

Post a Comment