FILTER TASK
REQUIREMENT:
You are give with an XML payload as shown below
<PersonalDetails>
<PersonalDetail>
<PersonID>2417</PersonID>
<Name>Alaika</Name>
<PhoneNumber>7207264400</PhoneNumber>
<Email>[email protected]</Email>
<State>Telangana</State>
<MartialStatus>No</MartialStatus>
<Job>CPI Consultant</Job>
</PersonalDetail>
</PersonalDetails>
Now there will be 5 receivers in which
1 st Receiver wants only Name without tags
2nd Receiver wants Phone number without tags
3 rd receiver wants Mail id with tags
4 th Receiver want Person Id if it exists then it should return the True
5th receiver should return payload based on name
SOLUTION:
Step 1:
Connect Sender to Integration Process by choosing HTTPS as adapter type
Now go to connection tab there give Address : /filters (you can give any name)
And also uncheck the CSRF checkbox.
STEP 2:
Now got to Routing pallete -> Multicast ->Parallel multicast.
Place the paralle multicast between the start and end points as shown below.
STEP 3:
Now got to Events Pallete and add remaining End Messages to the iflow and connect the
parallel multicast with all the receivers as shown below.
STEP 4:
Now go to the Transformation Pallete and add Filter to all the branches
STEP 5:
Now configure the filters
Click on Filter 1 -> go to processing tab and give Xpath expression as
/PersonalDetails/PersonalDetail/Name and change Value type to String as we want
only name without tags
Put start and stop simulation points for filter 1 --> click on start sim point and give XML
payload in Content--> click on OK. Now run the simulation
OUTPUT:
Click on Filter2 -> go to processing tab and give Xpath expression as
/PersonalDetails/PersonalDetail/PhoneNumber and change Value type to Integer as we
want without tags
Put start and stop simulation points for filter 2 --> click on start sim point and give XML
payload in Content--> click on OK. Now run the simulation
OUTPUT:
Click on Filter3 -> go to processing tab and give Xpath expression as
/PersonalDetails/PersonalDetail/Email and change Value type to Node as we want
with tags
Put start and stop simulation points for filter 3 --> click on start sim point and give XML
payload in Content--> click on OK. Now run the simulation
OUTPUT:
Click on Filter4 -> go to processing tab and give Xpath expression as
/PersonalDetails/PersonalDetail[PersonID = '2417'] and change Value type to Boolean
as we want output as True or False . It returns True if the given Id exists else false.
Put start and stop simulation points for filter 4--> click on start sim point and give XML
payload in Content--> click on OK. Now run the simulation
OUTPUT:
Click on Filter5 -> go to processing tab and give Xpath expression as
/PersonalDetails/PersonalDetail[Name= 'Alaika'] and change Value type to Nodelist .
Put start and stop simulation points for filter 5--> click on start sim point and give XML
payload in Content--> click on OK. Now run the simulation
OUTPUT: