Use the Message Element Setter mediation primitive to set the content of messages.
The Message Element Setter mediation primitive provides a simple mechanism for setting message content, it does not change the type of the message. You can change, add or delete message elements by setting the mediation primitive properties.
You can specify multiple message changes in one Message Element Setter mediation primitive by setting multiple targets. If multiple targets are set, all elements are effectively set simultaneously.
You can set target message elements to a constant value, or to a value copied from somewhere in the input Service Message Object (SMO). If a target message element you specify does not exist then it will be created in the SMO. You can also delete message elements if they are optional or repeating elements.
Target elements are specified as XPath expressions using the Target property. If you set a target message element to a constant value then the target XPath must resolve to a single leaf in an SMO node. If you set a target message element from a source message element, then both the source and target XPaths must resolve to a single message element (a single leaf or subtree). You can use the Value property to specify either a constant value or a source XPath expression.
The Message Element Setter mediation primitive has one input terminal and two output terminals. One output terminal is for successful output and one for failure output. The input terminal is wired to accept a message and the output terminals are wired to propagate a message. The successful output terminal propagates the modified message. If an exception occurs during the processing of the input message, then the fail terminal propagates the original message, together with any exception information.
It is often useful to combine the Message Element Setter mediation primitive with other mediation primitives. For example, you can use the Message Element Setter mediation primitive if you need to manipulate data, before or after the Database Lookup mediation primitive is invoked.
You can also use the Message Element Setter mediation primitive to change messages after filtering them, using the Message Filter mediation primitive. You might want to update or delete certain message elements after filtering.
If you want to set a target message element to a constant value, then the target XPath expression must resolve to a single leaf element. If you want to copy from a source message element to a target message element, then both the source and target must specify an XPath expression that resolves to a single message element (a single leaf or subtree).
If you set multiple targets, all elements are effectively set simultaneously. Therefore, if you set element X from value 13 to value 14, and element Y to the value of element X, the mediation will set element X to value 14 and element Y to value 13.
If you specify the same target element more than once then the last operation performed on the target element takes precedence.
Property | Valid Values | Default | |
---|---|---|---|
Message Elements | Target | String: An XPath expression | |
Type | String: copy or delete or Java primitive or Java String | ||
Value | String: An XPath expression or value compatible with Type property | ||
Validate input | Boolean: true or false | false |
Consider the following when using the Message Element Setter mediation primitive: