This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Property Mediator
The Property Mediator has no direct impact on the message, but rather on the message context flowing through Synapse. The properties set on a message can be later retrieved through the synapse:get-property(prop-name)
XPath extension function. If a scope is specified for a property, the property could be set as a transport header property or an (underlying) Axis2 message context property, or as a Axis2 client option. If a scope is not specified, it will default to the Synapse message context scope. Using the property element with action specified as remove
you can remove any existing message context properties.
Some Well-defined Properties that you can Get/Set on the Synapse Message Context Scope
Name | Values | Meaning |
---|---|---|
RESPONSE | true | "true" means the message is to be marked as a response message. |
OUT_ONLY | true | "true" means the message is to be marked as an out-only message that does not expect a response. |
ERROR_CODE | String | Is set to any error message code encountered during a fault. |
ERROR_MESSAGE | String | Is set to any error message text encountered during a fault. |
ERROR_DETAIL | String | Is set to any error message detail text encountered during a fault. |
ERROR_EXCEPTION | String | Is set to any Java Exception encountered during a fault. |
Some Axis2 and Module Properties that are Useful which are Set at scope="axis2"
Name | Values | Meaning |
---|---|---|
MercurySequenceKey | integer | Can be an identifier specifying an Mercury internal sequence key. |
MercuryLastMessage | true | "true" will make this the last message and terminate the sequence. |
Axis2 Client Side Property that is Useful which is Set at scope="axis2-client"
Name | Values | Meaning |
---|---|---|
FORCE_HTTP_1.0 | true | Forces outgoing http/s messages to use HTTP 1.0 (instead of the default 1.1). |
The synapse:get-property()
XPath Extension Function
The get-property()
function allows any XPath expression used in a configuration to look-up information from the current message context. It is possible to retrieve properties previously set with the property mediator, and/or information from the Synapse or Axis2 message contexts or transport header. The function accepts the scope as an optional parameter as shown below:
synapse:get-property( [(axis2 | axis2-client | transport),] <property_name> [,<dateformat>] )
Some Useful Properties from the Synapse Message Context Follows:
Name | Meaning |
---|---|
SYSTEM_DATE | Returns the current date as a String. Optionally a date format as per standard date format may be supplied. e.g. |
SYSTEM_TIME | Returns the current time in milliseconds, i.e. the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC. |
To, From, Action, FaultTo, ReplyTo, MessageID | The message To and Action and WS-Addressing properties. |
MESSAGE_FORMAT | Returns the message format, i.e. returns pox, get, soap11 or soap12. |
OperationName | Returns the operation name for the message. |
Tip
One may use the get-property()
function to retrieve Axis2 message context properties or transport headers. e.g. synapse:get-property('transport', 'USER_AGENT')
SynapseXpath Variables
There is a set of predefined XPath variables, when writing XPaths in the Synapse Configuration.
Name | Meaning |
---|---|
body | The SOAP 1.1 or 1.2 body element. For example, |
header | The SOAP 1.1 or 1.2 header element. For example, |
ctx | Prefix for Synapse MessageContext properties. For example, |
axis2 | Prefix for Axis2 MessageContext properties. For example, |
trp | Prefix for the transport headers. For example, |
Syntax
<property name="string" [action=set|remove] (value="literal" | expression="xpath") [scope=transport|axis2|axis2-client]/>
UI Configuration
You have the following configuration under the Property Mediator.
- Name - A name for the property. You can return the value of the property by calling
get-property(property-name)
XPath extension function. - Action - The action to do. Possible values are:
- Set - Adds a new property.
- Remove - Removes the property with the given name.
- Set Action As - Specifies which type of value to store. Possible values are:
- Value - A static text value.
- Expression - XPath expression to evaluate if there are any namespaces involved in the XPath expression, you can specify it in the Namespace Editor.
Tip
You can click this link to add namespaces if you are providing an expression. You will be provided another panel named "Namespace Editor," where you can provide any number of namespace prefixes and URL that you have used in the XPath expression.
- Type - Specifies the type of the property. Property mediator will handle the property as a property of selected type. Possible values are:
- STRING
- INTEGER
- BOOLEAN
- DOUBLE
- FLOAT
- LONG
- SHORT
OM
Tip
In default property mediator will consider any property as a STRING type property.
- Value/Expression
- Pattern - Specifies a regular expression that will evaluate against value of the property or result of the XPath expression.
- Group - Number (Index) of the matching item evaluated using regular expression given in "Pattern."
- Scope - Specifies the scope the property is valid. Possible values are:
- Synapse
- Transport
- Axis2
- axis2-client
Note
You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.
Example
In this example, we are setting the property symbol and later we are logging it using the Log Mediator.