Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to Extract Request XML Tag Value and Replace the Value based on Condition

satishms10
satishms10 Posts: 22

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,

  1. If the ID value is 30 or 80, send error responses
  2. 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,

  1. Created TestTable Data Source (screenshot attached above)
  2. Created two XML Message Responders
  3. One for ERROR responses with Responder Correlation to check for 30 and 80

  1. Second one for SUCCESS responses with Responder Correlation to check for NOT (30 and 80)

  1. 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