Ask a Question

[soapUI] retrieve response in a groovy script

Not applicable

[soapUI] retrieve response in a groovy script

Hi all,

I'm new at using soapUI and I'm trying to retrieve response in a groovy script.
I'm using soapui 3.5.1 the open source version and I'm builing a test case about a web service exposed by our application server.
I need to check if the response contains a given section.
I created a test case with 3 steps:
A) a groovy script for setting in a dynamic way some properties before invoking the web service
B) a test request
C) a groovy script for checking the response

My code in step C):

def groovyUtils = new;
def responseHolder = groovyUtils.getXmlHolder( messageExchange.responseContent);
responseHolder.namespaces["ser"] = ...;
String mySection = responseHolder["//ser:return"] ;
println mySection

but when I run my test case I got:

16:51:00,587 ERROR [SoapUI] An error occured [No such property: messageExchange for class: Script1], see error log for details

How should I retrieve the response ?

Thanks in advance

Re: [soapUI] retrieve response in a groovy script

Hi ferp,

access the response with

def responseHolder = groovyUtils.getXmlHolder( testRunner.testCase.testSteps["name of request step"].testRequest.response.responseContent );

(messageExchange is specific to Script Assertions)



Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Not applicable

Re: [soapUI] retrieve response in a groovy script

I am new to groovy , I did the same but it is giving me error
.No such property :groovy Utils
Occasional Visitor

Re: [soapUI] retrieve response in a groovy script

You need to import the GroovyUtils first. And use it in a static way, like:



def responseHolder = GroovyUtils.getXmlHolder( testRunner.testCase.testSteps["/your testStep"].testRequest.response.responseContent );


Re: [soapUI] retrieve response in a groovy script

and 'g' in GroovyUtils need to be capital

Showing results for 
Search instead for 
Did you mean: