Forum Discussion

ferp's avatar
14 years ago

[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

4 Replies

  • SmartBear_Suppo's avatar
    SmartBear Alumni (Retired)
    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)


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

      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 );