cancel
Showing results for 
Search instead for 
Did you mean: 

[soapUI] retrieve response in a groovy script

ferp
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 com.eviware.soapui.support.GroovyUtils(context);
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
ferp
4 REPLIES 4

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)

regards!

/Ole
eviware.com


Limited time: Gain insights – and win prizes – with our event “Inside Zephyr”! Runs May 17-28
prash
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
JamilMammi
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:

 

 

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

Sursuncity
Visitor

Re: [soapUI] retrieve response in a groovy script

and 'g' in GroovyUtils need to be capital

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