Create a WebSphere Commerce service module
The WebSphere Commerce service module contains all the assets used by a WebSphere Commerce service. If you are planning on providing new WebSphere Commerce services, you create a new service module, then further customize and extend the assets it creates. The Design Pattern Toolkit and the ComponentProjects design pattern are used to generate the base code for the new service module from a simple XML file. By describing the service module in a specialized XML syntax, the service modules can be generated. This allows you to start directly with the service module implementation without having to spends hours with the setup and configuration of a service module. Prerequisites
To create a new WebSphere Commerce service module:
- Start WebSphere Commerce Developer.
- Create the pattern application definition file to create the base code:
- Expand the ComponentProject folder.
- Right-click the components folder.
- Select New > Other.
- Select Simple > File and click Next.
- Enter MyServiceModule.appdef as the file name, where MyServiceModule is to be the name of your new service module.
- Click Finish.
- Double-click the MyServiceModule.appdef file to open it.
- Create the XML file to describe the WebSphere Commerce service module, starting by pasting the following XML sample (these are not the final values)
<commerce-component name="MyServiceModuleName" company="MyCompany" packagenameprefix="com.mycompany.commerce" namespace="http://www.mycompany.com/xmlns/prod/commerce/9/MyServiceModuleName" nlsprefix="mycompany" type="SOI/BOD"> <noun name="MyBusinessObject" get="true" process="true" change="true" sync="true"/> </commerce-component>This file is used to create the starter assets and configuration required to create a service module. Within this file, the subsystem and company information is required. Also required is each noun that is to be included with the subsystem and the supported verbs for that noun. Currently WebSphere Commerce supports only four verbs and the pattern addresses only these four verbs.- Replace the following values under commerce-component with values appropriate for your implementation:
- name=" MyServiceModule"
- The name of your new service module
- company=" MyCompany"
- The name of your company
- packagenameprefix="com. mycompany.commerce"
- Used to prefix the starter and generated code
- namespace=http://www.mycompany.com/xmlns/prod/commerce
- The namespace to associate with your component. This namespace should represent your organization.
- nlsprefix="mycompany"
- The xml schema prefix to associate with the name space. To avoid collision with the WebSphere Commerce prefix, avoid using an underscore (_) as the first character of the namespace prefix.
- type="SOI/BOD"
- Specify the type of service module. If you specify SOI, the pattern will create a service module that provides Service Oriented Integration into your existing controller commands, access beans, and EJBs. SOI is the only type of service module that can be created in Feature Pack 2. BOD can only be specified for WebSphere Commerce Feature Pack 3.
If you specify BOD, the pattern will create a Service Oriented Architecture service module that will use commands developed using the BOD command framework introduced in Feature Pack 3. These BOD commands will act upon Structured Data Objects (SDOs) and use the Business Object Mediator to persist and retrieve these SDOs. You must have downloaded and installed Feature Pack 3 to create BOD service modules.
- Replace the following values under noun:
- name=" MyBusinessObject" where MyBusinessObject is the name of your new noun.
For each of the verbs, Get Request / Show Response, Process Request / Acknowledge Response, Change Request / Respond Response, and Sync Request / ConfirmBOD Response, indicate whether you want to support this operation against your noun. For example:
- get="true"
- process="true"
- change="true"
- sync = "false"
You can create multiple <noun> elements in one service module, although in this example we just create one. Do not choose Get, Process, Change, or Sync as the name of your noun (they are reserved for use as verbs).
- Save the file (Ctrl S).
- Right-click MyServiceModule.appdef
- Select Apply Pattern.
- Select WebsphereCommerce Component Projects.
- Click OK.
- After the pattern is applied, verify that the following projects are created:
- MyServiceModule-Client
- Contains the client library Java code.
- MyServiceModule-DataObjects
- Contains the XSD, WSDL and generated SDOs.
- MyServiceModule-Server
- Contains the component facade implementation.
- MyServiceModule-UnitTests
- Contains a project designed for unit testing the client implementation.
- MyServiceModuleServicesHTTPInterface
- The Web module used to enable the service module for Web services over HTTP.
- MyServiceModuleServicesJMSInterface
- The EJB module used to enable the service module for Web services over JMS.
- Copy the folder TODO-MoveItToWCServerXMLFolder/xml from the MyServiceModule-Server project into the WCDE_installdir/xml directory.
- Enable the service module assets in WebSphere Commerce Developer.
- Next steps:
- Create your SDO genmodel file.
- Generate code from your SDO genmodel file.
- Create the component facade for an SOI service module.
Implementing the service commands in the BOD command framework
- Create the client library.
Related concepts
WebSphere Commerce services
WebSphere Commerce service module
Service Data Objects (SDO)
Client library for WebSphere Commerce services
Component facade interfaces
6.0.0.2Logging and tracing
Get Request and the Show Response
Process request and the acknowledge response
Change Request / Respond Response
Sync request and the ConfirmBOD responseRelated tasks
Testing a WebSphere Commerce service
Install the Design Pattern Toolkit and the ComponentProjects design pattern
Create the SDO genmodel file
Create the client library
Create the component facade