Ask a Question

Best way to repeatedly invoke a WebService which takes JSON as the input?

Occasional Contributor

Best way to repeatedly invoke a WebService which takes JSON as the input?



I am trying to use SoapUI to repeatedly invoke a Web Service (which is a Test Step), but supply a different application/json as the media type each time. I do not know the best way to perform this, so my approach was:


  1. - Create a Groovy script which contains an array of JSON objects
  2. - Create a Test Step property.
  3. - Loop the array and in each loop:
  4. - set the property to be the current JSON object
  5. - call the Test Step which invokes the web service. The application/json of the Test Step has a reference to the property


However this fails, because a property can only take a String and not take a JSON object.


Am I approaching this problem incorrectly? Is there a better way to parameterise calling a Test Step? I considered invoking the Web Service directly from Groovy, but felt that the strengths of asserting an existing Test Step (with all of its assertions) was the correct way of doing this.


If it helps, here is my Groovy script:


def currTestCase = context.testCase;

def ip = [
    '[ "Id": "Setting1", "Level" : "2" ]',
    '[ "Id": "Setting2", "Level" : "3" ]'

ip.each { it );
	currTestCase.setPropertyValue('myProp', it);
	testRunner.runTestStepByName( "Invoke User Setting")" iteration complete.");

// All tests complete. Stop




Occasional Contributor

I think you might be able to get away without using groovy, I would suggest the following approach (this answer is only applicable for SoapUI Pro:


1. Add step, Datasource: using a Directory (containing .json files) OR JSON info:

2. Add step, REST Request

3. Add step, Datasource loop 

4. Add step, Assertions etc.



Occasional Contributor

Thanks - that was helpful!

Showing results for 
Search instead for 
Did you mean: