Forum Discussion

TejasParmar's avatar
TejasParmar
Occasional Contributor
6 years ago
Solved

Re: How to run a loop dynamically using values received in a response in SOAP UI Pro

Hi Lucian,   Thanks for the prompt response :) . I tried with script you gave, currently it is not going into while loop. Not sure what the issue is. If you can please help me on that. the result a...
  • Lucian's avatar
    6 years ago

    The response comes as "referenceId":"value" (no blanks between the key and value). You just have to modify the while loop as in:

     

    // Find all reference ids in the GetReferenceIds test step
    while ( rawResponse.indexOf( "referenceID\":") != -1 ){
    	rawResponse = rawResponse.substring( rawResponse.indexOf( "referenceID\":\"") + "referenceID\":\"".length() )
    	referenceIds.add( rawResponse.substring( 0, rawResponse.indexOf( "\"" ) ) )
    	rawResponse = rawResponse.substring( "referenceID\":\"".length() )
    	log.info referenceIds  //check for referenceIds
    }

    Let me know if it works!