Create the SDO genmodel file

Prerequisites

Before beginning this task, ensure you have completed the following tasks:

  1. Installed WebSphere Commerce Developer

  2. Enabled WebSphere Commerce services

  3. Created a WebSphere Commerce service module

  4. Copy the xsd, ecore, and wsdl folders from WCDE_installdir\workspace\WebServicesRouter\WebContent\component-services to MyServiceModule-DataObjects.

If you are extending an existing WebSphere Commerce noun, you do not need to perform these prerequisite steps - the service module has already been created.

The examples in this task use a service module called MyServiceModule, and a company called MyCompany.

The examples in this file illustrate generating SDOs for the AcknowledgeMyServiceModule, ProcessMyServiceModule, and SyncMyServiceModule messages and the MyServiceModule noun.

There are some particular considerations when creating these schemas. Each noun schema should include an Ecore annotation, which is additional metadata about the schema that the SDO code generator can use when generating code from the schema. For example, the Order noun has the additional header information:

<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
        xmlns:oa="http://www.openapplications.org/oagis/9"
       
xmlns:msm="http://com.mycompany.commerce/xmlns/prod/commerce/9/myservicemodule"
      
        attributeFormDefault="unqualified"
elementFormDefault="qualified" 
       
targetNamespace="http://com.mycompany.commerce/xmlns/prod/commerce/9/myservicemodule"
        ecore:nsPrefix="msm" 
       
ecore:package="com.mycompany.commerce.myservicemodule.facade.datatypes">

These instructions tell the SDO code generator that every type defined under the namespace http://www.ibm.com/xmlns/prod/commerce/9/myservicemodule should have a corresponding Java type created in the package com.mycompany.commerce.myservicemodule.facade.datatypes. The nsPrefix is currently ignored by the tooling, but it is included for completeness; it effectively gives a name to the factory class for objects in this namespace.

To create the SDOs:

  1. Start WebSphere Commerce Developer.

  2. The first step is to create the genmodel file. This is an EMF model asset, that is initialized from a set of XSD schemas. To create the genmodel:

    1. Highlight the service module's DataObjects project under Other Projects in the Project Explorer. Left-click, and then right-click New > Other.

    2. Select the Show All Wizards check box.

    3. Expand Eclipse Modeling Framework and select EMF Models.

  3. Give the new genmodel file a name. A good practice is to name the genmodel file based on the nsPrefix name defined for your noun. Change the parent folder to MyServiceModule-DataObjects/ecore.

  4. Select Load from an XML Schema and click Next.

  5. Click Browse Workspace and select the list of XSD schemas to include in the model. You should include all of your message BODs. You do not need to specify the nouns explicitly, because these are specified by the BODs. Click Next.

  6. On the next dialog box is the list of namespaces that the tooling detected while parsing the XSD schemas that you specified. Notice the com.mycompany.commerce.myservicemodule.facade.datatypes package. This is the one that you want to generate from this model, so be sure to select it.

  7. An error message will appear at the top of the dialog. This is indicating that the model cannot be created because there is a dependency on other namespaces that are not being generated. In particular, the message refers to a number of OAGIS namespaces, and also the Commerce Foundation namespace. The EMF models for these types have already been created, so you don't want to regenerate them in this model. Instead, click the Browse button to add references to existing genmodel files such as Foundation.genmodel from MyServiceModule-DataObjects.

  8. Choose the Foundation genmodels to import. After they are added, select the imported namespaces that you need:

  9. Click Finish.

Related concepts

WebSphere Commerce services
WebSphere Commerce service module
Service Data Objects (SDO)

Related tasks

Generating code from an SDO genmodel file
Updating Service Data Objects