The parameters available for configuring the Property mediator are as follows:
A name for the property.
The action to be performed for the property.
|Set Action As|
The possible values for this parameter are as follows:
The data type for the property. Property mediator will handle the property as a property of selected type. Available values are as follows.
String is the default type.
|Value||If the Value option is selected for the Set Action As parameter, the property value should be entered as a constant in this parameter.|
If 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
|Pattern||This 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.|
|Group||The 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.
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.
This example was added for the FAQ How can I send a fault message based on (with the contect-type of) 'Accept' http header?. If you edit this section, please edit the FAQ as well.
Example 3: Reading a property stored in the Registry
You can read a property that is stored in the Registry by using the
get-property() method in your Synapse configuration. For example, the following Synapse configuration retrieves the
abc property of the collection
gov:/data/xml/collectionx, and stores it in the
<property name="regProperty" expression="get-property('registry', 'gov:/data/xml/collectionx@abc')"/>
You can use the following syntaxes to read properties or resources stored in the
Reading a property stored under a collection
Reading a property stored under a resource
Reading an XML resource
Example 4: Reading a file stored in the Registry
Following is an example, in which you read an XML file that is stored in the registry using XPath, to retrieve a value from it. Assume you have the following XML file stored in the Registry (i.e.,
<root> <book>A Song of Ice and Fire</book> <author>George R. R. Martin</author> </root>
Your Synapse configuration should be as follows. This uses XPath to read XML.
<property name="xmlFile" expression="get-property('registry','gov:/test.xml')" scope="default" type="OM"></property> <log level="custom"> <property name="Book_Name" expression="$ctx:xmlFile//book"></property> </log>
Your output log will look like this.
[2015-09-21 16:01:28,750] INFO - LogMediator Book_Name = A Song of Ice and Fire