Develop > Persistence layer > Work with WebSphere Commerce services


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 Java Emitter Template (JET) 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.


Before you begin


Procedure

To create a new WebSphere Commerce service module:

  1. Start WebSphere Commerce Developer.

  2. Create the pattern application definition file to create the base code:

    1. Create the service module input file.

      1. Right-click on the WebSphereCommerceServerExtensionsLogic project and select New > Other > XML > XML and click Next.

      2. Click Next.

      3. Select Create XML file from an XML schema file and click Next.

      4. Select Select file from Workspace, select WC > xml > config > xsd > wc-component-pattern.xsd and click Next.

      5. Click Finish.

    2. Create the XML file to describe the WebSphere Commerce service module, starting by pasting the following XML sample (these are not the final values):

      <_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="MyServiceModuleName" packagenameprefix="com.mycompany.commerce" company="MyCompany"
          namespace="http://www.mycompany.com/xmlns/prod/commerce/9/MyServiceModuleName" nlsprefix="myco" type="SOI/BOD">  
      <_pattern:noun name="MyBusinessObject" get="true" process="true" change="true" sync="false" /> 
      </_pattern:commerceComponent> 
      

      Where My Company is the company name. 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.

    3. Replace the following values under commerceComponent with values appropriate for the implementation:

      name=" MyServiceModule"

      The name of the new service module

      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 the component. This namespace should represent the 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 the existing controller commands, access beans, and EJBs.

      If you specify BOD, the pattern will create a service-oriented architecture service module that will use commands developed using the BOD command framework. These BOD commands will act upon Structured Data Objects (SDOs) and use the Business Object Mediator to persist and retrieve these SDOs.

    4. Replace the following values under noun:

      • name=" MyBusinessObject" where MyBusinessObject is the name of the new noun.

        Nouns define the name of each data element in the logical model, and assign that name to a data type. The data type can be a primitive XML schema type such as boolean, or a complex type. A complex type is a construct of data elements such as CurrencyType which contains price (represented by a double type) and currency (represented as a string). A noun can contain one or more noun parts (sometimes referred to as noun elements). A Noun part is a complex XML type within a noun that can be acted upon independently. Noun parts represent parts of a logical noun. Separating a noun into parts simplifies coding by reducing the scope of commands and mediators. Instead of handling the entire noun, code is limited to only processing the noun part. When a request arrives, it is broken into its different parts and the appropriate command for each part is run. For example, the CatalogEntry noun contains a list of descriptions. A catalogEntry description is considered a noun part and is processed using the ChangeCatalogEntryDescriptionCmdImpl and ChangeCatalogEntryDescriptionMediator.

      For each of the verbs, Get Request / Show Response, Process Request / Acknowledge Response, Change Request / Respond Response, and Sync Request / ConfirmBOD Response, indicate whether to support this operation against the 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).

    5. Save the file (Ctrl S).

  3. Right-click MyServiceModule.xml and select Run As > Input for Jet Transformation.

  4. In the Transformation section:

    1. Select the following ID:

      • com.ibm.commerce.toolkit.internal.pattern.componentprojects

    2. Click OK.

  5. 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.

    • You can ignore the compilation error messages at this time. Java objects representing the noun do not yet exist, and are generated in the next step. In addition, the newly generated projects are not yet added to the WebSphere Commerce Application and cannot resolve dependencies on WebSphere Commerce code.

    • Each generated project will also contain a prefix, either SOI or BOD, depending on the selected type of the implementation. For example, MyServiceModule-Client would be either SOIMyServiceModule-Client or BODMyServiceModule-Client.

      • If you specify SOI, the pattern will create a service module that provides service-oriented integration into the existing controller commands, access beans, and EJBs.

      • If you specify BOD, the pattern will create a service-oriented architecture service module that will use commands developed using the BOD command framework. These BOD commands will act upon Structured Data Objects (SDOs) and use the Business Object Mediator to persist and retrieve these SDOs.

  6. Add the generated modules to the Websphere Commerce Application.

  7. Next steps:

    1. Create the SDO genmodel file.

    2. Generate code from your SDO genmodel file.

    3. Create the component facade for an SOI service module.

    4. Implement the service commands in the BOD command framework

    5. Create the client library.


Related concepts

WebSphere Commerce Web services

WebSphere Commerce service module

Service Data Objects (SDO)

Client library for WebSphere Commerce services

Component facade interfaces

Log and tracing

Get Request and the Show Response

Process request and the acknowledge response

Change Request / Respond Response

Sync request and the ConfirmBOD response


Related tasks

Test a WebSphere Commerce service

Create and updating Service Data Objects (SDO)

Create the client library

Create the component facade


+

Search Tips   |   Advanced Search