Forum Discussion

abhishekc17's avatar
abhishekc17
New Contributor
12 years ago

Compare XML Response using SoapUI and writing to Database

Hi All,
I am very new to SOAPUI and I have come across a situation where I need to compare two XML Responses within a test case and if they do not match then log it to the database. After my research I found that there are two ways of doing it
1) Adding an Assertion ( Since I am using a SOAP UI PRO) - This was easy to setup however, I am unable to write the assertion results to a log ( in my case database)
2) So I went for a Groovy script - I have never worked with Groovy script before and I wanted some help in figuring out how to write code for it. below is the code I came up with so far but I get an error -

Code I used -

def LagacyResponse = context.expand( '${Legacy Call(app1)#Response#declare namespace ns1=\'com.rovicorp.metadataservice\'; //ns1:searchResponse[1]/ns1:results[1]/ns1:result[1]/ns1:id[1]}' )

def NewResponse = context.expand( '${New Call(app 2)#Response#declare namespace ns1=\'com.rovicorp.metadataservice\'; //ns1:searchResponse[1]/ns1:results[1]/ns1:result[1]/ns1:id[1]}' )

IF (LagacyResponse == NewResponse)-------------------Here I am comparing the two XML responses but it fails here
{
log.info "Status:Testcase passed"

}
ELSE {
testRunner.fail( runner.reason )
///////////////Database code not added yet.

}


Any help would be great.


Ab

2 Replies

  • HI,
    Let me look into that link.The error which I get is

    groovy.lang.MissingMethodException: No signature of method: Script1.IF() is applicable for argument types: (java.lang.Boolean, Script1$_run_closure1) values: [true, Script1$_run_closure1@26e3fde7] Possible solutions: run(), run(), any(), is(java.lang.Object), wait(), dump()
    -> error at line: 4

    And yes I meant 'Legacy' but since it is a variable, the spelling should not matter.