Creating the message model

This topic describes how to create the message model, and includes the following sections:

Creating the message definitions

To create the message definitions, you must create the following:

  1. A message set project, and a message set.
  2. Three message definition files, one for each namespace used in the Video Rental sample.
  3. A message called Customer.

Use the following instructions to create the message definitions. There are detailed instructions for some of the following steps; to access them click the link provided at the end of the step.

  1. Switch to the Broker Application Development perspective.
  2. Create a new message set called Video, in a message set project called Video Message Sets. For instructions, see Creating a message set project.
    1. Select the options to create CWF, XML, and TDS physical formats. Use the default names (CWF1, XML1, and TDS1). When you use the wizard to create a new message set project, the wizard creates a new message set at the same time.
  3. Create the following message definition files in the Video Message Sets project. For instructions, see Creating a message definition file.
    1. Create a message definition file called Customer, accepting the default values.
      When you click Finish, a file called Customer.mxsd is displayed in the Broker Development view under Video > (default).
    2. Create a message definition file called Address.
      Click Use target namespace. Type http://www.ibm.com.addressdetails in the Namespace field, and addr in the Prefix field. When you click Finish, a namespace called com.ibm.www.addressdetails is displayed under the Video message set in the Broker Development view. A file called Address.mxsd is displayed under "com.ibm.www.addressdetails".
    3. Create a message definition file called Borrowed.
      Click the Use target namespace radio button. Type http://www.ibm.com.borroweddetails in the Namespace field, and brw in the Prefix field. When you click Finish, a namespace called www.ibm.com.borroweddetails is displayed under the Video message set in the Broker Development view. A file called Borrowed.mxsd is displayed under "borroweddetails".
  4. View the namespace settings for the message set:
    1. In the Broker Development view, double-click messageSet.mset to open it.
    2. In the Message Set editor, in the Properties Hierarchy, click XML1. Expand Namespace settings. You can now view the settings you made in the steps above.
  5. Add a new message, called Customer, to the Customer message definition file. For instructions, see Adding a message.
    A complex type called ComplexType1 is automatically created for the message. Rename this complex type to CustomerType.
    Note that you do not need to add messages to the other message definition files at this point. Elements from Address and Borrowed will be added into the Customer message in the following section.

Adding elements, types, and groups

When you have created the message definitions, add elements, types, and groups to those message definitions. Start by adding elements, types, and groups to the Address and Borrowed message definitions. After this, import the borroweddetails and addressdetails namespaces into the default namespace. This is required so that you can then add the elements Address and Borrowed to the Customer message definition.

There are several ways in which you can add types and elements to your message and still achieve the same outcome. The sequence given here is only one way of creating a message, but adding the elements and types in the following order can help you to see more clearly how the message is structured.

Adding elements and types to the Address message definition file

To add elements and types to the Address message definition file, create a global element called Address, and then a local complex type. After that, you can add more elements to the Address message definition file.

To create a global element called Address, and a local complex type:

  1. Switch to the Broker Application Development perspective.
  2. In the Broker Development view, double-click Address.mxsd to open it.
  3. In the Outline view, right-click Elements and Attributes, and click Add Global Element. An element called globalElement1, of type string, is added. Rename this element to Address.
  4. In the Message Definition editor, highlight the row on which Address appears. In the Type column, click the cell that displays the default value "string", to reach a pulldown menu of available types. Select New Complex Type. The property "Create a local complex type" is selected by default.
  5. Click OK. In the Outline view, a type called {Local complexType} appears under Address.

You can now add more elements to the Address message definition. Create the elements listed in the following table. For example, to add HouseNo:

  1. Right-click {Local complexType}, and click Add Local Element. An element called localElement1 of type string is added under {Local complexType}. Rename this element to HouseNo.
  2. In the Message Definition editor, highlight the row on which HouseNo appears. In the Type column, click the cell that displays the default value "string" to reach a pulldown menu of available types. Select int.
Element Type
HouseNo int
Street string
Town string

Adding elements and types to the Borrowed message definition file

To add elements and types to the Borrowed message definition file, create a global element called Borrowed, create a local complex type, and add the elements listed in the table below. Use the instructions in the previous section.

Element Type
VideoTitle string
DueDate dateTime
Cost decimal

Importing the borroweddetails and addressdetails namespaces into the default namespace

Before you can add the elements Borrowed and Address (from the borroweddetails and addressdetails namespaces respectively) into the Customer message, you must import the borroweddetails and addressdetails namespaces into the default namespace:

  1. Switch to the Broker Application Development perspective.
  2. In the Broker Development view, double-click Customer.mxsd to open it.
  3. In the Message Definition editor, click Customer.mxsd, then click the Properties tab.
  4. In the Properties Hierarchy, right-click Imports, and click Add Import. The Select Message Definition File to Import window opens.
  5. Expand the tree until you reach Address.mxsd, and click Finish.

Repeat the above steps for Borrowed.mxsd.

The Address.mxsd and Borrowed.mxsd files are displayed in the Properties Hierarchy under Imports. Click them to see the settings you made above. The Prefix field displays the value you specified in the Prefix field when you created the message definition file. The Namespace field displays the value you specified in the Namespace field.

Adding elements, types, and groups to the Customer message definition file

You must now add elements, types, and groups to the Customer message definition file, and then add element, attribute, and group references to types and groups.

Add elements, types, and groups

To add elements, types, and groups:

  1. Switch to the Broker Application Development perspective.
  2. In the Broker Development view, double-click Customer.mxsd to open it and click the Overview tab.
  3. In the Outline view, right-click Types, and click Add Complex Type. Add a complex type called NameType.
  4. Right-click Groups, and click Add Group. Add a group called IdGroup.
  5. Right-click Elements and Attributes, and click Add Global Element. Add the elements listed in the table below, and change their types accordingly:
    1. In the Message Definition editor, click the Overview tab.
    2. Highlight the row on which the element appears.
    3. In the Type column, click the cell that displays the default value "string" to reach a pulldown menu of available types, and select the type required. In addition to the simple types (such as string, integer, or boolean), the menu now also contains the complex types you added in step 3. As a result, you can now change the type of the element Name to NameType. To add NameType, you might need to first select (More...) from the pulldown menu.
    Element Type
    Title string
    FirstName string
    ID string
    PassportNo string
    DrivingLicenseNo string
    CreditCardNo string
    Name NameType
    Magazine boolean
  6. Right-click Elements and Attributes, and click Add Global Attribute. Add the following global attribute:
    Global Attribute Type
    LastName string

Add element, attribute, and group references

To add element references to IdGroup:

  1. Switch to the Broker Application Development perspective.
  2. In the Outline view, expand Groups.
  3. Right-click IdGroup, and click Add Element Reference. Add references to the following elements:

To add element and attribute references to NameType:

  1. Switch to the Broker Application Development perspective.
  2. In the Outline view, expand Types.
  3. Right-click NameType, and click Add Element Reference. Add references to the following elements, in the following order:
  4. Right-click NameType, and click Add Attribute Reference. Add a reference to the global attribute called LastName.

    The position of LastName under NameType is not significant because it is an attribute and, as such, is not treated the same way as elements are at runtime.

To add element, attribute, and group references to CustomerType, follow the instructions below. It is important that you add the references in the order they are presented here.

  1. Switch to the Broker Application Development perspective.
  2. In the Outline view, expand Types.
  3. Right-click CustomerType, and click Add Element Reference. Add references to the following elements: This element addr:Address is from the addressdetails namespace. If you had not imported the addressdetails and borroweddetails namespaces into the default namespace earlier, this element would not be available for you to add to CustomerType. You add this element reference exactly the same way as any other element reference, but you can see that it is prefixed by the Namespace URI value you set when you create the Address message definition file.
  4. Right-click CustomerType, and click Add Group Reference. Add a reference to the following group:
  5. Right-click CustomerType, and click Add Element Reference. Add a reference to the following element:

When you have completed the tasks on this page and have added all the required elements, types, and groups to the message definitions files, you can configure the message model.

Back to sample home