Tutorials > Program model > Web services > Create an outbound Web service client for WebSphere Commerce

< Previous | Next >


Create a task command to send and receive messages

In this step, we will create a new task command that will build a PushUser request SDO, 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 on 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 on the com.mycompany.commerce.member.client.commands package.

    7. Select New > Interface

      1. In the name field, type: MyCompanyPushUserCmd.

      2. Next to the Extended interfaces field, Click Add.

      3. Enter TaskCommand.

      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. Copy and paste 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 the file ( Ctrl S).

  2. Create the MyCompanyPushUserCmdImpl task command to populate the request message.

    1. Right-click on the com.mycompany.commerce.member.client.commands package.

    2. Select New > Class.

      1. In the Name field, type: MyCompanyPushUserCmdImpl

      2. Next to the Superclass field, click Browse.

      3. Enter TaskCommandImpl

      4. Click OK.

      5. Next to the interfaces field, Click Add.

      6. Enter MyCompanyPushUserCmd

      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 the file ( Ctrl s).

< Previous | Next >


+

Search Tips   |   Advanced Search