omer khalid
omer khalid

Reputation: 895

WSO2 ESB 4.8.1 Switch Mediator Case matching not working

I am using WSO2 ESB 4.8.1. I need to check if a particular field exists in the Incoming Payload XML. If Iit does, a Switch Case should run, otherwise it should run a default scenario. The field on which I am checking will always have a dynamic value and it would look like following:

20000569899

I wrote following logic in ESB:

 <property name="CheckIdExist" expression="//*[local-name()='Id']" scope="default" type="STRING" description="CheckIdExist"/>
    <switch source="get-property('CheckIdExist')">
        <case regex="[a-zA-Z0-9]">
            <sequence key="SequenceA"/>
            <sequence key="SequenceB"/>
            <sequence key="SequenceC"/>
        </case>
        <default>
           <log></log>
        </default>
    </switch>

Problem:

The problem is that Switch is able to pick a value from the property but it does not match the Case regular expression. Following are some ESB Logs Entries:

Logs Entries:

XPath : get-property('CheckIdExist') evaluates to : 20001089900

None of the switch cases matched - executing default

I checked online, this regular expression works. So what i am unable to understand is that why WSO2 ESB is not recognizing it as a valid expression. Or is there any other way to check that if a field exists in an input request then a particular switch case should work, Otherwise not.

Upvotes: 4

Views: 2401

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627380

Your regular expression lacks a quantifier + meaning 1 or more occurrences:

<case regex="[a-zA-Z0-9]+">

Upvotes: 2

Related Questions