Forum Discussion

rajnani's avatar
rajnani
Occasional Contributor
15 years ago

Reading the input from previous step

Hi, I have a test case where I invoke a web service and then I have a groovy script where I get the request sent in the previous step and log the message (in soap UI pro 3.0). In the request message I am substituting values for some of the elements with data read from a file. For example

${ReadFromFile#MemberNumber}

This works fine when invoking the webservice ie., values are substituted appropriately. But when I get the request message in the next step (groovy) this value is coming as is i.e., as shown above without substituted values.

I used the following code to read the input message

def testStep = testRunner.testCase.getTestStepByName("RedeemPoints");
def requestMsg = testStep.getProperty ("request");
return requestMsg.value;

Is there any way to get the request message as sent with substituted values. Please let me know.

Thanks
Raj

2 Replies

  • brr7907's avatar
    brr7907
    Occasional Contributor
    I think you need to implement a listener for this.  It looks like you are running a groovy script as a test step.  Instead you want to implement the listener so that after every test step you can see the request that was submitted and the response that was returned.

    There are examples of how to implement listeners here -> http://www.soapui.org/architecture/extensions.html

    If you decide to use Java instead of Groovy, BE CAREFUL...the example in the documentation above is WRONG.  The Java example compiles, but do to a method overloading mistake in the example it does not work.

    I assume the Groovy example works, but I have not tried it.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Raj.

    you can get the actual message xml sent via the TestStepResult object created for the request; if your groovy step is after the request you can try

    log.info( testRunner.results[testRunner.results.size()-1].requestContent )

    Does that help?

    regards!

    /Ole
    eviware.com