Message mappers

A message mapper is a mechanism that takes an XML message and converts it to a CommandProperty object. It provides a common interface so that messages can be converted to CommandProperty objects and used by all WebSphere Commerce components.

The CommandProperty object is a representative of a controller command. The object contains the command name to be executed, the command properties when executing the command, and the parameters of the command. The purpose of the message mappers is to convert inbound request messages into controller commands to be executed by an adapter. Although they can be used by all components of WebSphere Commerce to map data into a extended TypedProperty object, the main purpose for message mappers is converting XML objects into common Java objects that represents controller commands.

The CommandProperty datatype is composed of the following three parts:

Supported adapters, such as the Program Adapter, and WebSphere Commerce components can both call a message mapper. For both, the message mapper performs the following tasks:

Inbound messages are sent to WebSphere Commerce by back-end systems or external systems to request some sort of action. In order for WebSphere Commerce to perform that action, the XML message must be processed by the message mapper to determine what action has been requested. WebSphere Commerce includes two message mappers at installation: the XML message mapper for parsing XML integration messages, and the legacy message mapper for parsing back-end integration legacy messages.

The CommandProperty object represents a WebSphere Commerce command to accommodate the requirements from the supported device adapters. Other components can also use the message mapper mechanism to convert messages to CommandProperty objects.

The lifecycle of a message mapper exists throughout the WebSphere Commerce instance. It is initialized when an instance is started and it resides as long as the instance runs. WebsSphere Commerce provides three message mappers: XML message mapper, XML message mapper for SOAP message, and the legacy message mapper.

The WebSphere Commerce configuration file lists all possible message mappers, and includes their name, class, device format, whether they are available, and specific configuration parameters. To locate the parameters for a certain message mapper, find the component name in the MessageMapperGroup. Since each message mapper may have different configuration attributes, each has a separate MessageMapperGroup element. The only requirement for the format of the configuration parameters element is that the attributes must be name-value-pairs. This allows the message mapper configuration parameters to be easily converted to a TypeProperty object.

The following lists the parameters for each individual message mapper:


XML message mapper

The XML message mapper is responsible for converting the XML data from inbound XML messages to CommandProperty objects. It is an extension of the ECSAX parser. The XML message mapper found in the WebSphere Commerce configuration file should look similar to the following:

When the XML message mapper parses an inbound XML message, it gets the document type, the version if it is available, and the element name, one by one from the XML documents in the message. The message mapper looks up the template document defined in the ECTemplate element of the template definition file. The template document tells the message mapper the following information:

Once the tag mapping has started, the message mapper looks in the TemplateTag, as defined in the ECTemplate file to determine the field name and type based on the XPath generated from the inbound XML message, then sets a value for that field. The field and value pairs are stored in a TypedProperty hash table of either commandProperty or messageProperty, based on the value in the FieldInfo attribute for that field. After the whole inbound message is parsed successfully, a PropertyCommand object is returned, which contains the command name as well as the commandProperty and messageProperty objects.

To support different versions for one message, multiple template document can be specified. For example,

If the configuration element is empty, then the Messaging element will be used. The Messaging is found inside WebSphere Commerce configuration file.


XML message mapper for SOAP messages

The XML message mapper for SOAP messages is responsible for extracting the XML data from inbound SOAP messages and converting it to CommandProperty objects. It is an extension of the ECSAX parser. The message mapper found in the WebSphere Commerce configuration file should look similar to the following:


Legacy message mapper

The legacy message mapper is responsible for converting the data from inbound legacy messages to CommandProperty objects. The legacy message mapper found in the WebSphere Commerce configuration file should look similar to the following:


Related concepts
WebSphere Commerce configuration file (wc-server.xml)


Related tasks
Adding message mappers
Removing message mappers


Related reference
TemplateTag element of a template definition file