Tutorials > Program model > Web services > Create an outbound Web service client for WebSphere Commerce
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
- Create the MyCompanyPushUserCmd command interface.
- In the Enterprise Explorer view, expand the WebSphereCommerceServerExtensionsLogic project.
- Right-click on the src folder.
- Select New > Package.
- In the name field, type com.mycompany.commerce.member.client.commands.
- Click Finish.
- Right-click on the com.mycompany.commerce.member.client.commands package.
- Select New > Interface
- In the name field, type: MyCompanyPushUserCmd.
- Next to the Extended interfaces field, Click Add.
- Enter TaskCommand.
- Click OK.
- Click Finish.
- Add the following import statements to the interface:
import com.ibm.commerce.user.objects.UserAccessBean; import com.mycompany.commerce.member.facade.datatypes.PushUserConfirmationType;
- 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();
- Save the file ( Ctrl S).
- Create the MyCompanyPushUserCmdImpl task command to populate the request message.
- Right-click on the com.mycompany.commerce.member.client.commands package.
- Select New > Class.
- In the Name field, type: MyCompanyPushUserCmdImpl
- Next to the Superclass field, click Browse.
- Enter TaskCommandImpl
- Click OK.
- Next to the interfaces field, Click Add.
- Enter MyCompanyPushUserCmd
- Click OK.
- Click Finish.
- Replace the contents of this class with the contents of the following downloadable sample code: MyCompanyPushUserCmdImpl.java
- Save the file ( Ctrl s).