I need to extract screeningRequestData from below xml request.
<ScreeningRequest> <region>BLR</region> <serviceInvokerName>xyz</serviceInvokerName> <screeningRequestData> <Request ClientID='458aEw-8c24-4bbc-813d-770a375fe6a9' Id='1004'> <Field Name='ID' UniqueField='Y'>0000000024</Field> <Field Name='Name' NameField='Y'>test Ltd</Field> <Field Name='Entity Type'>Org</Field> <Field Name='Reference #' NameField='N'>Test Ltd</Field> <Field Name='Address Line 1[1]'>5 th Street</Field> <Field Name='Town-City[1]'>Test City</Field> <Field Name='Country[1]' NameField='Y'>Test Country</Field> </Request> </screeningRequestData> </ScreeningRequest>
I am using following ExtractVariables policy.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="EV.ExtractScreeningRequestParams"> <DisplayName>EV.ExtractScreeningRequestParams</DisplayName> <Properties/> <XMLPayload> <Namespaces/> <Variable name="region" type="string"> <XPath>/ScreeningRequest/region</XPath> </Variable> <Variable name="serviceInvokerName" type="string"> <XPath>/ScreeningRequest/serviceInvokerName</XPath> </Variable> <Variable name="screeningRequestData" type="string"> <XPath>/ScreeningRequest/screeningRequestData</XPath> </Variable> </XMLPayload> <Source clearPayload="false">request</Source> </ExtractVariables>
However, it assign following string to screeningRequestData
0000000024 test Ltd Org Test Ltd 5 th Street Test City Test Country
But I need following data in screeningRequestData
<Request ClientID='458aEw-8c24-4bbc-813d-770a375fe6a9' Id='1004'> <Field Name='ID' UniqueField='Y'>0000000024</Field> <Field Name='Name' NameField='Y'>test Ltd</Field> <Field Name='Entity Type'>Org</Field> <Field Name='Reference #' NameField='N'>Test Ltd</Field> <Field Name='Address Line 1[1]'>5 th Street</Field> <Field Name='Town-City[1]'>Test City</Field> <Field Name='Country[1]' NameField='Y'>Test Country</Field> </Request>
How to fetch part of xml data from xml request?
Solved! Go to Solution.
Try changing the type to "nodeset" for screeningRequestData variable.
Basically, your Extract variable policy will now be :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="EV.ExtractScreeningRequestParams"> <DisplayName>EV.ExtractScreeningRequestParams</DisplayName> <Properties/> <XMLPayload> <Namespaces/> <Variable name="region" type="string"> <XPath>/ScreeningRequest/region</XPath> </Variable> <Variable name="serviceInvokerName" type="string"> <XPath>/ScreeningRequest/serviceInvokerName</XPath> </Variable> <Variable name="screeningRequestData" type="nodeset"> <XPath>/ScreeningRequest/screeningRequestData</XPath> </Variable> </XMLPayload> <Source clearPayload="false">request</Source> </ExtractVariables>
This will give the variable as :
Try changing the type to "nodeset" for screeningRequestData variable.
Basically, your Extract variable policy will now be :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="EV.ExtractScreeningRequestParams"> <DisplayName>EV.ExtractScreeningRequestParams</DisplayName> <Properties/> <XMLPayload> <Namespaces/> <Variable name="region" type="string"> <XPath>/ScreeningRequest/region</XPath> </Variable> <Variable name="serviceInvokerName" type="string"> <XPath>/ScreeningRequest/serviceInvokerName</XPath> </Variable> <Variable name="screeningRequestData" type="nodeset"> <XPath>/ScreeningRequest/screeningRequestData</XPath> </Variable> </XMLPayload> <Source clearPayload="false">request</Source> </ExtractVariables>
This will give the variable as :
From the above context,once we extract the below element, how can I compare to check it matches the received region value="texas", if the value doesn't match will reject and throw error something like http 400 with an error msg.
/ScreeningRequest/region
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |