I have a sequence as part of proxy service which filters based on "Source and Regular Expression". I have defined source as element value coming as part of SOAP request and regular expression as "local entry defined in ESB". However, result is not what I am expecting.
Local Entry is defined as Inline Text (myFields) - FIELD1|FIELD2|FIELD3
Mediation sequence is defined as - <sequence xmlns="http://ws.apache.org/ns/synapse" name="007"> <property xmlns:ns="http://org.apache.synapse/xsd" name="fieldName" expression="$body/fieldName/text()" scope="default" type="STRING"/> <filter xmlns:ns="http://org.apache.synapse/xsd" source="get-property('fieldName')" regex="get-property('myFields')"> <then> <log level="full" separator="*****YES*********"> <property name="myFields" expression="get-property('myFields')"/> </log> </then> <else> <log level="full" separator="*********NO**************"> <property name="myFields" expression="get-property('myFields')"/> </log> </else> </filter> </sequence>
When I am sending SOAP request as - <body> <fieldName>FIELD1</fieldName> </body>
execution is always going to else part. Any suggestion ?
With filter mediator, regex attribute must be a string, not an expression.
You can use XPATH2 "matches"
Sample :
<inSequence>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property name="fieldName" expression="$body/fieldName/text()"/>
<property xmlns:fn="http://www.w3.org/2005/xpath-functions" name="match" expression="fn:matches(syn:get-property('fieldName'),syn:get-property('myFields'))"/>
<filter source="get-property('match')" regex="true">
<then>
<log level="full" separator="*****YES*********">
<property name="myFields" expression="get-property('myFields')"/>
</log>
</then>
<else>
<log level="full" separator="*********NO**************">
<property name="myFields" expression="get-property('myFields')"/>
</log>
</else>
</filter>
<log level="full"/>
</inSequence>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.