All docs This doc
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 20 Next »

The Property Mediator has no direct impact on the message, but rather on the message context flowing through Synapse. You can retrieve the properties set on a message later through the get-property(prop-name) extension function or, for better performance, the Synapse XPath Variables. A property can have a defined scope for which it is valid. If a property has no defined scope, it defaults to the Synapse message context scope. Using the property element with the action specified as remove, you can remove any existing message context properties.

See Properties Reference for a list of various types of properties supported by WSO2 ESB with descriptions and use cases.

The Property mediator is a conditionally content aware mediator.


<property name="string" [action=set|remove] [type="string"] (value="literal" | expression="xpath") [scope=default|transport|axis2|axis2-client] [pattern="regex" [group="integer"]]>

UI configuration

The parameters available for configuring the Property mediator are as follows: 

Parameter NameDescription
NameA name for the property.

The action to be performed for the property.

  • Set: If this is selected, the property will be set in the message context.
  • Remove: If this is selected, the property will be removed from the message context.
Set Action As

The possible values for this parameter are as follows:

  • Value: If this is selected, a static value would be considered as the property value and this value should be entered in the Value parameter.
  • Expression: If this is selected, the property value will be determined during mediation by evaluating an expression. This expression should be entered in the Expression parameter.


The data type for the property. Property mediator will handle the property as a property of selected type. Available values are as follows.

  • LONG
  • OM

String is the default type.

The OM type is used to set xml property values on the message context. This is useful when the expression associated with the property mediator evaluates to an XML node during mediation. When the OM type is used, the XML is converted to an AXIOM OMElement before it is assigned to a property.

ValueIf the Value option is selected for the Set Action As parameter, the property value should be entered as a constant in this parameter.
ExpressionIf the Expression option is selected for the Set Action As parameter, the expression which determines the property value should be entered in this parameter. This expression can be an XPath expression or a JSONPath expression.  

When specifying a JSONPath, use the format json-eval(<JSON_PATH>), such as json-eval(getQuote.request.symbol). In both XPath and JSONPath expressions, you can return the value of another property by calling get-property(property-name). For example, you might create a property called JSON_PATH of which the value is json-eval(pizza.toppings), and then you could create another property called JSON_PRINT of which the value is get-property('JSON_PATH'), allowing you to use the value of the JSON_PATH property in the JSON_PRINT property. For more information on using JSON with the ESB, see JSON Support.

You can click NameSpaces to add namespaces if you are providing an expression. Then the Namespace Editor panel would appear where you can provide any number of namespace prefixes and URLs used in the XPath expression. 

PatternThis parameter is used to enter a regular expression that will be evaluated against the value of the property or result of the XPath/JSON Path expression.
GroupThe number (index) of the matching item evaluated using the regular expression entered in the Pattern parameter.

The scope at which the property will be set or removed from. Possible values are as follows.

  • Synapse: This is the default scope. The properties set in this scope last as long as the transaction (request-response) exists.
  • Transport: The properties set in this scope will be considered transport headers. For example, if it is required to send an HTTP header named 'CustomHeader' with an outgoing request, you can use the property mediator configuration with this scope.
  • Axis2: Properties set in this scope have a shorter life span than those set in the Synapse scope. They are mainly used for passing parameters to the underlying Axis2 engine
  • axis2-client: This is similar to the Synapse scope. The difference between the two scopes is that the axis2-client scope can be accessed inside the mediate() method of a mediator via a customs mediator created using the Class mediator. See axis2-client for further information.
  • Operation: This scope is used to retrieve a property in the operation context level.
  • Registry: This scope is used to retrieve properties within the registry .  
  • System: This scope is used to retrieve Java system properties.

See XPath Extension Functions for a detailed explanation of each scope.


You can configure the mediator using XML. Click switch to source view in the Mediator window.


Example 1: Setting and logging and property

In this example, we are setting the property symbol and later we can log it using the Log Mediator.

<property name="symbol"
	expression="fn:concat("Normal Stock - ', //m0:getQuote/m0:request/m0:symbol)"

<log level="custom">
	<property name="symbol" expression="get-property('symbol')"/>

Example 2: Sending a fault message based on the Accept http header

In this configuration, a response is sent to the client based on the Accept header. The PayloadFactory mediator transforms the message contents. Then a Property mediator sets the message type based on the Accept header using the $ctx:accept expression. The message is then sent back to the client via the Respond mediator.


There are predefined XPath variables (such as $ctx) that you can directly use in the Synapse configuration, instead of using the synapse:get-property() function. These XPath variables get properties of various scopes and have better performance than the get-property() function, which can have much lower performance because it does a registry lookup. For more information on these XPath variables, see Synapse XPath Variables.

<payloadFactory media-type="xml">
        <m:getQuote xmlns:m="http://services.samples">
<property name="messageType" expression="$ctx:accept" scope="axis2" />
  • No labels