ReadyAPI can be used for testing both SOAP and REST services. Output format of them is mainly XML / JSON. Hence it is important to know how to parse them into corresponding objects.
Parsing XML
Consider a scenario where output for a SOAP service or JDBC call is returning a XML containing list of person information, which we need to convert to objects.
XML format is like below, which available as a response content of a ReadyAPI Step
User XMLSlurper to parse the response content to XML document
Iterate over the rows and create an object and add to a list
123456789101112131415161718192021
//Create an objectclassPerson{StringFirstNameStringLastNameIntegerAge}//Parse response content string to XML objectdefResults=newXmlSlurper().parseText(messageExchange.responseContent)log.info"Number of records :"+Results.ResultSet.Row.size();// Iterate over each row and convert to obhectdefDBRecordList=newArrayList<Person>();for(recordinResults.ResultSet.Row){defobj=newPerson();obj.FirstName="${record.FIRSTNAME}";obj.LastName="${record.LastName}";obj.Age=${record.Age};DBRecordList.add(obj);}