Creating a task command to send and receive messages

In this lesson, you create a task command that builds a PushUser request SDO. You use the MyCompanyMember client API to transmit the message and handle the PushUserConfirmation response SDO.

Procedure

  1. Create the MyCompanyPushUserCmd command interface.
    1. In the Enterprise Explorer view, expand the WebSphereCommerceServerExtensionsLogic project.
    2. Right-click the src folder.
    3. Select New > Package.
    4. In the name field, type com.mycompany.commerce.member.client.commands.
    5. Click Finish.
    6. Right-click the com.mycompany.commerce.member.client.commands package.
    7. Select New > Interface.
      1. In the name field, type: MyCompanyPushUserCmd.
      2. Click the Add button next to the field Extended interfaces.
      3. Enter TaskCommand in the Choose interfaces input field.
      4. Click OK.
      5. Click Finish.
    8. Add the following import statements to the interface:
      
      import com.ibm.commerce.user.objects.UserAccessBean;
      import
      com.mycompany.commerce.member.facade.datatypes.PushUserConfirmationType;
      
    9. Add the following into the interface body:
      
      /**
       * The full name of this command.
       */
      public static final String NAME =
      "com.mycompany.commerce.member.client.commands.MyCompanyPushUserCmd";
      
      /**
       * The default implementation of this command.
       */
      public static final String defaultCommandClassName = NAME + "Impl";
      
      /**
       * The invocation service action
      <code>CreateUser</code>.
       */
      public static final String ACTION_CREATE_USER = "CreateUser";
      
      /**
       * The invocation service action
      <code>UpdateUser</code>.
       */
      public static final String ACTION_UPDATE_USER = "UpdateUser";
      
      /**
       * Sets the invocation service action.
       * @param action the invocation service action.
       */
      public void setAction(String action);
      
      /**
       * Sets the user ID.
       * @param userID the user ID.
       */
      public void setPushUserID(Long userID);
      
      /**
       * Sets the user access bean.
       * @param user the user access bean.
       */
      public void setPushUser(UserAccessBean user );
      
      /**
       * Returns the PushUserConfirmation SDO.
       * @return the PushUserConfirmation SDO.
       */
      public PushUserConfirmationType getResponse();
      
    10. Save and close the file.
  2. Create the MyCompanyPushUserCmdImpl task command to populate the request message.
    1. Right-click the com.mycompany.commerce.member.client.commands package.
    2. Select New > Class.
      1. In the field Name, type: MyCompanyPushUserCmdImpl
      2. Click the Browse button next to the field Superclass.
      3. Enter TaskCommandImpl in the Choose a type input field.
      4. Click OK.
      5. Click the Add button next to the field interfaces.
      6. Enter MyCompanyPushUserCmd in the Choose interfaces input field.
      7. Click OK.
      8. Click Finish.
    3. Replace the contents of this class with the contents of the following downloadable sample code: MyCompanyPushUserCmdImpl.java
    4. Save and close the file.