WebSphere WebSphere Enterprise Service Bus, Version 6.0.2 Operating Systems:

Message Element Setter mediation primitive

Use the Message Element Setter mediation primitive to set the content of messages.

Introduction

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.

Usage

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.

Properties

Message Elements
Message elements on an SMO node.
Target
An XPath 1.0 expression that describes the location of the element to set, create or delete. You can specify an XPath expression that starts with: /, /body, /headers, or /context. / refers to the complete SMO, /body refers to the body section of the SMO, /headers refers to the headers of the SMO and /context refers to the context of the SMO.

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.

Type
The type of the element value. If you want to set the Target to a constant value then the Type must be a Java primitive or Java String. If you want to set the Target to a value copied from somewhere in the input SMO, then the Type must be the keyword copy. When you copy a value from somewhere in the input SMO, then the target type is assumed to be the same as the source type. If you want to delete an element instance then the Type must be the keyword delete. You can only delete optional or repeating elements.
Value
If the Type property is set to copy then the Value property should be an XPath 1.0 expression, indentifying the source element. A copy operation always takes its source value from the unmodified input SMO. If the Type property is set to delete then the Value property should not be set. If the Type property is neither copy nor delete, then the Value and Type properties must be compatible. For example, if the Type is int then the Value could validly be 14, but not GoldAccount.
Validate input
If true, causes the input message to be validated before the mediation is performed.
Table 1. Message Element Setter mediation primitive properties
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

Considerations

Consider the following when using the Message Element Setter mediation primitive:


Reference topic

Terms of Use | Rate this page

Timestamp iconLast updated: 29 Oct 2006
http://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?topic=/com.ibm.wbit.help.medprim602.doc\ref\rwesb_MessageElementSettermediationprimitive.html

(C) Copyright IBM Corporation 2005. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)