How to Extract Request XML Tag Value and Replace the Value based on Condition
Hi, I am creating a virtual service in Parasoft. I am using below request xml.
<?xml version="1.0" encoding="UTF-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header> </s:Header> <s:Body> <WorkItem> <IncomingData> <Enquiry> <EnquiryUId>3</EnquiryUId> <EnquiryBasics> <EnquiryBasicExtra> <DataItemName>FA_INDICATOR</DataItemName> <DataItemValue>N</DataItemValue> </EnquiryBasicExtra> </EnquiryBasics> <Parties> <Party> <ID>10</ID> </Party> <Party> <ID>70</ID> </Party> </Parties> </Enquiry> </IncomingData> </WorkItem> </s:Body> </s:Envelope>
I have a table of values from which I need to do Data Source Correlation using ID field from the incoming request xml.
Table Data Source:
My requirement is,
- If the ID value is 30 or 80, send error responses
- If the ID value is NOT (30 and 80), send success response
- During success response, I need to check other condition. If the ID is "< 30" or "> 90", change the value to 50 before the data source correlation so that it will match with first row from Table Data Source
Here is the solution that I have started with,
- Created TestTable Data Source (screenshot attached above)
- Created two XML Message Responders
- One for ERROR responses with Responder Correlation to check for 30 and 80
- Second one for SUCCESS responses with Responder Correlation to check for NOT (30 and 80)
- am trying to add below groovy code under "Incoming Request -> Extension Tool" to check if the ID is "< 30" or "> 90", change the value to 50 before the data source correlation I