aaron_ehrensber
15 years agoContributor
Scripting WebService call
I have a groovy script in which I basically want to loop over the results from a previous webservice call, snag the results, and send a subsequent webservice request.
(In a nutshell - make call A to get 10 IDs from system, loop 10 times and make 10 requests). I have the loop in place and can access the 10 responses....
My script is ...
I have 2 questions....
1. The addGroupFeatureRights is the webservice call I wish to make. Am I correct in the way I'm attempting to set the properties in that call?
2. The webservice call... The classificationId tag, for example, is just <classificationId></classificationId> Do I need to put anything in the tag to tell it to reference the value that I'm passing in?
Thank you in advance for any help.
Aaron
(In a nutshell - make call A to get 10 IDs from system, loop 10 times and make 10 requests). I have the loop in place and can access the 10 responses....
My script is ...
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def requestHolder = groovyUtils.getXmlHolder ("getFeatureRights#Response" )
requestHolder.declareNamespace("ns2","http://host:port/webservices/PermissionWebServices/")
def featureRightList = requestHolder.getNodeValues("//ns2:getFeatureRightsResponse[1]/featureRights");
int counter = 1
int loopControl = featureRightList.length + 1;
while (counter < loopControl ) {
def classId = requestHolder.getNodeValue("//ns2:getFeatureRightsResponse[1]/featureRights[" + counter + "]/classificationId[1]");
def featureRightId = requestHolder.getNodeValue("//ns2:getFeatureRightsResponse[1]/featureRights[" + counter + "]/id[1]");
testRunner.testCase.testSteps["addGroupFeatureRights"].setPropertyValue("classificationId", classId)
testRunner.testCase.testSteps["addGroupFeatureRights"].setPropertyValue("featureRightId", featureRightId)
// run the webservice
def result = testRunner.runTestStepByName("addGroupFeatureRights");
String status = result.getStatus().toString();
log.info (status);
counter++;
}
[code]
I have 2 questions....
1. The addGroupFeatureRights is the webservice call I wish to make. Am I correct in the way I'm attempting to set the properties in that call?
2. The webservice call... The classificationId tag, for example, is just <classificationId></classificationId> Do I need to put anything in the tag to tell it to reference the value that I'm passing in?
Thank you in advance for any help.
Aaron