Add message mappers
To add a new message mapper, we must manually add it to the group of message mappers in the WebSphere Commerce configuration file.
Procedure
- Open the WebSphere Commerce configuration file.
- Locate MessageMapperGroup element.
- Define your message mapper, add a MessageMapper element as a child element to the MessageMapperGroup element.
<component compClassName="com.ibm.commerce.programadapter.messagemapper.MessageMapperGroup" enable="true" name="MessageMapperGroup"> <property display="false"> <MessageMapper messageMapperId="new mapper id" classname="class implementing MessageMapper interface" enable="true" name="Name of Message Mapper"> <configuration EcSystemTemplateFile="my-component-services-system-template.xml" EcUserTemplateFile="my-component-services-user-template.xml" EcInboundMessageDtdFiles="something.dtd" EcTemplatePath="some_dir" EcSaxParserClass="org.apache.xerces.parsers.SAXParser" EcInboundMessageDtdPath="some_dir" isValidating="false" DebugMode="FALSE" EmptyElementClearsData="FALSE"/> </MessageMapper>
Where:
- messageMapperId
- An integer from -100 to -9999. It must be unique in the MessageMapperGroup.
- classname
- The name of the class implementing the MesssageMapper interface. For example, com.ibm.commerce.messaging.programadapter.messagemapper.ecsax.ECSAXMessageMapper.
Notes:
- If you do not define EcSystemTemplateFile and EcUserTemplateFile in <MessageMapper>, the default message values are used. The default values - EcSystemTemplateFile and EcUserTemplateFile - are located in the WebSphere Commerce configuration file <Messaging> element. If EcSystemTemplateFile, EcUserTemplateFile, or both are defined, the default <Messaging> values are not used.
- If EcInboundMessageDtdPath and EcInboundMessageDtdFiles are not specified in <MessageMapper>, the default values are used. The default values are located in the WebSphere Commerce configuration file <Messaging> element. If EcInboundMessageDtdPath, EcInboundMessageDtdFiles, or both are defined, the default <Messaging> values are not used.
- If EcSystemTemplateFile or EcUserTemplateFile contains an empty value (for example EcSystemTemplateFile="") a NullPointerException is thrown.
- Within the <configuration> element, add any additional configuration attributes that the message mapper needs. This is converted into a TypedProperty object and passes to the init method of the message mapper.
Note: In order to have your message mappers function properly, ensure that we are using the newer implementation class name of the XML parser, EcSaxParserClass="org.apache.xerces.parsers.SAXParser".
- Add this message mapper name to the list of message mapper names in the "supportedMessageMappers" attribute of the configuration element of the target program adapter, as is described in Configure the Program Adapter.
Related concepts
WebSphere Commerce configuration file (wc-server.xml)
Message mappers
Related tasks
Removing message mappers
Configure the Program Adapter