Forum Discussion

risenshine's avatar
13 years ago

How to loop soap request from properties?

Hi Everyone,
I am running a test where I get a list of servers (around 50) and now I wish to perform the following actions:
1. Store this list as individual Testsuite properties - (Done!)
2. Start a loop and transfer the control to run the test cases that I wish to run with the value of loop running. (Need help at this step)
3. Loop another soap request using one of these servers (as an input) at a time (Need help at this step)
4. Search for the text in the response I receive after execution - (Done!)

Here is what I tried so far:
For Step 1:
int count=1;
def Servers = []
def testCase = testRunner.testCase.testSuite.project.getTestSuiteByName("Experiment")
while (context.expand( '${RequestForServers#Response#//ns2:OperationListResponse[1]/ns2:OperationListResult[1]/diffgr:diffgram[1]/NewDataSet[1]/Table['+count+']/ItemID[1]}') !="" )
{
System.out.println("Value of count is = "+count);
Servers[count] = context.expand( '${RequestForServers#Response#//ns2:OperationListResponse[1]/ns2:OperationListResult[1]/diffgr:diffgram[1]/NewDataSet[1]/Table['+count+']/ItemID[1]}')
System.out.println("Value of Server is = "+Servers[count]);
testCase.setPropertyValue("Server"+count,Servers[count])
count = count+1
}

For Step 2:

int i
def ServerResponseTime
for (i=1;i<=50;i++)
{
System.out.println("Value of Loop "+i);
testRunner.runTestStepByName( "ServerResponseTime")
ServerResponseTime = context.expand( '${ServerResponseTime#Response#//ns2:EnhancedMetricsByTimeResponse[1]/ns2:EnhancedMetricsByTimeResult[1]/diffgr:diffgram[1]/NewDataSet[1]/metrics[2]/Srt[1]}')
System.out.println("Server Response Time="+ServerResponseTime)
testRunner.runTestStepByName( "GetMetrics")
System.out.println("Value of Loop "+i);
testRunner.runTestStepByName( "Verification")
System.out.println("Value of Loop "+i);
}

For Step 3

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sup="http://netqos.com/SuperAgentWS">
<soap:Header/>
<soap:Body>
<sup:EnhancedMetricsByTime>
<!--Optional:-->
<sup:network/>
<!--Optional:-->
<sup:server>${#TestSuite#Servers}</sup:server>
<!--Optional:-->
<sup:application/>
<sup:utcStartTime>${#TestSuite#UTZStartTime}</sup:utcStartTime>
<sup:utcEndTime>${#TestSuite#UTZEndTime}</sup:utcEndTime>
<!--Optional:-->
<sup:metricIds>
<!--Zero or more repetitions:-->
<sup:SAEnhancedMetrics>ServerResponseTime</sup:SAEnhancedMetrics>
</sup:metricIds>
<sup:includeMaintenance>true</sup:includeMaintenance>
</sup:EnhancedMetricsByTime>
</soap:Body>
</soap:Envelope>

Any help is appreciated.

Thanks!
No RepliesBe the first to reply