Creating the message model
This topic describes how to create the message model, and includes the following sections:
- Creating the message definitions
- Adding elements, types, and groups
Creating the message definitions
To create the message definitions, you must create the following:
- A message set project and a message set, see
Message set projects,
and a Message sets overview
in the WebSphere Message Broker documentation.
- Three message definition files,
one for each namespace that is
used in the Video Rental sample, see
Message definition files and
Namespaces in the message model
in the WebSphere Message Broker documentation.
- A message called Customer.
Use the following instructions to create the message definitions.
Links to more detailed instructions for some of the following steps are
provided at the end of the step.
- Create a new message set called Video, in a message set project called Video Message Sets.
For instructions, see
Creating a message set
in the WebSphere Message Broker documentation.
- 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.
- Create the following message definition files in the Video Message Sets project.
For instructions, see
Creating a message definition file
in the WebSphere Message Broker documentation.
- 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).
- 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.
- Create a message definition file called Borrowed.
Select 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".
- View the namespace settings for the message set:
- In the Broker Development view, double-click
messageSet.mset to open it.
- In the Message Set editor, in the Properties Hierarchy, click
XML1.
Expand Namespace settings.
You can now view the settings you made in the previous steps.
- Add a new message, called Customer, to the Customer message definition file.
For instructions, see Adding a message
in the WebSphere Message Broker documentation.
A complex type called ComplexType1 is automatically created for the message.
Rename this complex type to CustomerType.
Note that you do not have to add messages to the other message definition files at this point.
Elements from Address and Borrowed are 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.
Import the borroweddetails and addressdetails namespaces into the default namespace.
This action 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 one way of creating a message,
but adding the elements and types in the following order can help
you to see 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. You can then add more elements to the
Address message definition file.
To create a global element called Address, and a local complex type:
- In the Broker Development view, double-click
Address.mxsd to open it.
- 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.
- In the Message Definition editor
highlight the row in which Address is shown, see
Message Definition editor
in the WebSphere Message Broker documentation.
In the Type column, click the cell that displays the default value
string,
to see a menu of available types.
Select New Complex Type.
The property "Create a local complex type" is selected by default.
- 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:
- 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.
- In the Message Definition editor, highlight the row in which HouseNo is shown.
In the Type column, click the cell that displays the default value
string
to see a 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 following table.
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)
into the Customer message, you must import the borroweddetails
and addressdetails namespaces into the default namespace:
- In the Broker Development view, double-click
Customer.mxsd to open it.
- In the Message Definition editor, click Customer.mxsd,
click the Properties tab.
- In the Properties Hierarchy, right-click Imports,
and click Add Import.
The Select Message Definition File to Import window opens.
- 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 Address.mxsd and Borrowed.mxsd
to see the settings.
The Prefix field displays the value that you
specified in the Prefix field
when you created the message definition file.
The Namespace field displays the value that 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:
- In the Broker Development view, double-click the
Customer.mxsd file to open it,
and click the Overview tab.
- In the Outline view, right-click Types,
and click Add Complex Type.
Add a complex type called NameType.
- Right-click Groups, and
click Add Group.
Add a group called IdGroup.
- Right-click Elements and Attributes, and click
Add Global Element.
Add the elements listed in the following table, and change their types accordingly:
- In the Message Definition editor, click the
Overview tab.
- Highlight the row in which the element is shown.
- In the Type column, click the cell that displays the default value string
to see a 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 |
- 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:
- In the Outline view, expand Groups.
- Right-click IdGroup,
and click Add Element Reference.
Add references to the following elements:
- PassportNo
- DrivingLicenseNo
- CreditCardNo
To add element and attribute references to NameType:
- In the Outline view, expand Types.
- Right-click NameType, and click
Add Element Reference.
Add references to the following elements, in the following order:
- Title
- FirstName
- 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,
use the following instructions.
It is important that you add the references in the order they are presented here.
- In the Outline view, expand Types.
- Right-click CustomerType, and
click Add Element Reference.
Add references to the following elements:
The element addr:Address is from the addressdetails namespace.
This element is available for you to add to CustomerType because you have already
imported the addressdetails and borroweddetails namespaces into the default namespace.
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 that
you set when you created the Address message definition file.
- Right-click CustomerType, and
click Add Group Reference.
Add a reference to the following group:
- Right-click CustomerType, and
click Add Element Reference.
Add a reference to the following elements:
- brw:Borrowed (This element is from the borroweddetails namespace)
- Magazine
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