You can't simply do a string regex matching, if you are to check the non-existence of a property. What you could do is to leverage the boolean Xpath function [1], within a filter mediator.
Please see the following sample proxy configuration:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TEST" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<filter source="boolean(get-property('accept'))" regex="false">
<then>
<log level="custom">
<property name="*********" value="NULL Property Value"/>
</log>
</then>
<else>
<log level="custom">
<property name="*********" value="NOT NULL Property Value"/>
</log>
</else>
</filter>
<send/>
</inSequence>
<outSequence>
<log/>
<send/>
</outSequence>
</target>
<description></description>
</proxy>
Hope this will save some amount of time of quite a bit of you :-)
[1] http://www.w3.org/TR/xpath/#function-boolean
3 comments:
This is really useful. Thank you for the blog post :)
I had it as ... regex="'false'" (with ticks) Did NOT work! Must only be double quotes.
That was a waist of an hour because I didn't notice the difference here. LOL Thank you for this great post!!!! Still helping people.
Thank you. This has helped me.
Post a Comment