Showing results for 
Search instead for 
Did you mean: 

SOAP UI 5.0-groovy Automation

Occasional Contributor

SOAP UI 5.0-groovy Automation

Hi All,

I have an automation task. I wanted to compare two different soap responses and come with an output.

My 1st soap response will have certain tags like this :



My 2nd response will have following tags but with same data as in 1st response:




I wanted to compare personId with PersonIdentification and mainID with mainIdentity and so on...

Anyone has a solution for this?

Occasional Contributor

We have a separate mapping document an excel sheet.. we will see that compare
Community Hero

You can create that mapping from excel sheet into groovy if needed.

Community Hero

First I request you to try the script with fixed data, then with your responses.

Occasional Contributor

@nmrao  your code is Perfect 200%


I wanted to know this how to fetch nodeNames and parentNodeName if you are given with the nodeValue..

for eg.






Now I have only number 123 and hifiCity (values) with this can I fetch back nodeName and ParentNodeName?


Frequent Contributor

It seems you are well on the way to completing this but missing the final step, which should not be dissimilar to the regular approach to data driven testing.  However instead of loading expected values I would load a set a of mappings/bindings.  I would define a properties file that maps one set of names to the other, so taking your table, its contents would something like:  PrimarySourceName = SecondarySourceName.  Then Get the values from each source and use the mapping to get the values for comparison. file

Placed in the same directory as your project.


Load the Properties



// location of mapping properties is relative to SOAPUI project file.
def groovyUtils = new GroovyUtils( context )
String mappingFile = groovyUtils.projectPath + "/"

// load the properties
Properties properties = new Properties()
File propertiesFile = new File(mappingFile)
propertiesFile.withInputStream {


Assuming REST requests are made in previous steps, the responses are retrived

def sourceOneResponse = new XmlSlurper().parseText(requestOne.response)
def sourceTwoResponse = new XmlSlurper().parseText(requestTwo.response)


Then loop through the entries and compare values of each


for (property in properties) {
	sourceOneName =	
	sourceOneValue = sourceOneResponse.getNodeValue(sourceOneName)
	sourceTwoName = property.value
	sourceTwoValue = sourceTwoResponse.getNodeValue(sourceTwoName)
	assert sourceOneValue == sourceTwoValue : "${sourceOneName} : ${sourceOneValue} is not equal to ${sourceTwoName} : ${sourceTwoValue}"





New Here?
Join us and watch the welcome video:
Top Kudoed Authors