Forum Discussion

andrewhl's avatar
12 years ago

Generate Dynamic Request?

Hi,

I have some basic knowledge of using SoapUI. I am currently working on the TestCase where I need to loop to generate a dynamic request that is based on earlier request/response.

Below are the TestSteps I have
1. Add TestRequest Soap "A". Send Soap request message and the Soap response contains a list of messageIds.
2. Add Property Transfer "StoreResponse". Store the Soap response from Soap "A" to the TestCase's property, "response"
3. Add TestRequest Soap "B". Send Soap request message that contains empty messageId. This request will be used by the groovy script.
4. Add Groovy Script. The script uses the XmlSlurper to parse the Soap response "response" from "StoreResponse" that contains the list of messageId. Get the list of messageId.
Do a loop on each messageId and edit the TestRequest Soap "B" but how to edit the request? Any suggestion?
After the request edit, then execute the TestRequest Soap "B" to send the Soap request.


Below is the example

def popResponse = new XmlSlurper().parseText(response)
def popCountXml = popResponse.count
int count = 0
while(count < popCountXml .toInteger()) {
def msgId = popResponse.header[count].messageId.text()

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder("StoreResponse#Request")

holder["//Body/send/messageId"] = msgId
holder.updateProperty()
testRunner.runTestStepByName("StoreResponse")
count++;



Is the above correct way to handle dynamic requests?

Thanks
Andrew
No RepliesBe the first to reply