Property mediator¶
The Property mediator is used to define configuration settings that control how an integration behaves. These properties manage transport settings, security configurations, or mediator-specific parameters that influence message processing. The Property mediator allows you to set or remove these properties, ensuring they are available within the mediation flow.
Note
With the introduction of the Variable mediator in WSO2 MI 4.4.0 onwards, it is now recommended to use the Property mediator only for managing configuration-related properties within a mediation flow. To store data for future use, the Variable mediator should be used instead.
Syntax¶
<property name="string" [action="set"|"remove"] [type="STRING"|"INTEGER"|"BOOLEAN"|"DOUBLE"|"FLOAT"|"LONG"|"SHORT"|"OM"|"JSON"]
(value="string" | expression="expression") [scope="default"|"transport"|"axis2"|"axis2-client"|"operation"|"registry"|"system"|"env"|"file"]
[pattern="regex" [group="integer"]]></property>
Configuration¶
The parameters available to configure the property mediator are as follows:
Parameter Name | Description |
---|---|
Property Name | A name for the property. You can provide a static value or a dynamic value for the property name. A dynamic property name can be retrieved by using an expression. Note that the expression should be contained within curly brackets (
For names of the generic properties that come by default, see Generic Properties. |
Property Action | The action to be performed for the property.
|
Property Data Type | The data type for the property. Property mediator will handle the property as a property of selected type. Available values are as follows:
Note STRING is the default type.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.JSON type is used to set JSON values on the message context. It is recommended to use the JSON
data type (rather than the STRING data type) for JSON payloads.
Example 1: Creating a property with a JSON string by giving the value.
|
Property Value | You can give either value or an expression.
|
Pattern | This parameter is used to enter a regular expression that will be evaluated against the value of the property or the result of the expression. |
Group | The number (index) of the matching item is evaluated using the regular expression entered in the Pattern parameter. |
Scope | The scope at which the property will be set to or removed from. Possible values are as follows.
For a detailed explanation of each scope, see scopes documentation. |
Examples¶
Send 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.
<payloadFactory media-type="xml">
<format>
<m:getQuote xmlns:m="http://services.samples">
<m:request>
<m:symbol>Error</m:symbol>
</m:request>
</m:getQuote>
</format>
</payloadFactory>
<property name="messageType" expression="$ctx:accept" scope="axis2"/>
<respond/>
Set the HTTP status code¶
The Property mediator can be used to set the HTTP status code for responses. In the example below, the status code is set to 500
.
<property name="HTTP_SC" value="500" scope="axis2"/>