Reply
Highlighted
Occasional Contributor
Posts: 9
Registered: ‎08-23-2016

getProperty("rawRequest") does not return the 'real' request sent

I'm using a REST request (POST) that look like this:

 

<ns1:Bundle>
         <ns1:id value="${=UUID.randomUUID().toString()}"/>
         <ns1:timestamp value="${=new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSS-05:00").format(new Date())}"/>
</ns1:Bundle>

 

When I click on the Raw from the Test Step I see this:

 

<ns1:Bundle>
      <ns1:id value="bd1fc767-6edb-43fd-9482-c265492e1004"/>
      <ns1:timestamp value="2017-02-17T12:04:19.0915-05:00"/>
</ns1:Bundle>

 

I need those two values for another message, but whatever method I use for instance this Groovy:

 

def rawReq = testRunner.testCase.testSteps['test'].testRequest.response.requestContent
def rawReq2 = testRunner.testCase.testSteps['test'].getProperty("rawRequest").getValue()
log.info rawReq
log.info rawReq2

 

I always get another UUID and another timestamp than the one in the 'real' raw message that was sent !

 

<ns1:Bundle>
    <ns1:id value="2345d4a6-306f-4f7b-95c8-c3c3e93b90ad"/>
    <ns1:timestamp value="2017-02-17T12:04:19.0953-05:00"/>
</ns1:Bundle>

 

What is the problem ? It looks like the parameter are re-evaluate when running the Groovy script...

Does anyone have a solution ?

 

Thanks

 

Jan Potters

Frequent Contributor
Posts: 104
Registered: ‎08-04-2016

Re: getProperty("rawRequest") does not return the 'real' request sent

@JanPot, in such case I would prefer to:

  • use properties on the test case (or test suite) level,
  • initialize their values with the SetUp script and
  • use them inside the service requests as e.g. ${#TestCase#myId}

This approach seems to me more straightforward and in my opinion achieves what you need.

 

Karel

 

Occasional Contributor
Posts: 9
Registered: ‎08-23-2016

Re: getProperty("rawRequest") does not return the 'real' request sent

Thanks Karel,

 

This is finally what I did, but I cannot get it out of my head that this is a bug :-) Why say that the getProperty returns the value of the rawRequest when it is not ?

 

Regards,

 

Jan

Frequent Contributor
Posts: 104
Registered: ‎08-04-2016

Re: getProperty("rawRequest") does not return the 'real' request sent

@JanPot, the properties of SoapUI objects are not always simple strings.

 

Sometimes the naming of user interface label does not correspond directly to the object bellow.

 

In your case the rawRequest triggers the request evaluation (inline groovy code is evaluated) and then you get a brand new raw request. However, it is not the last message exchange of the test step run.

 

When I need to get the request or response message of the last test step run, I use testRunner.getResults() collection, which contains WsdlTestRequestStepResult instances for SOAP Request test steps.

 

Anyway, more description in SoapUI API documentation would be helpful to avoid such confusions.

 

Karel

 

Occasional Contributor
Posts: 9
Registered: ‎08-23-2016

Re: getProperty("rawRequest") does not return the 'real' request sent

Hi Karel,

 

thank you very much for your help. I tried to apply your last solution, but I can't kind a get to understand it... Would you be so helpful and tell me how I could use testRunner.getResults() collection in the context of my example ?

 

Regards,

 

Jan

Frequent Contributor
Posts: 104
Registered: ‎08-04-2016

Re: getProperty("rawRequest") does not return the 'real' request sent

@JanPot, I believe the right way for your use case is to utilize the test case properties.

 

But if you are interested how to get the request and response messages of the last test run, you can check this code:

 

import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStepResult

testRunner.results.each {
        def stepResult = it
        if (stepResult instanceof WsdlTestRequestStepResult) {
            log.info stepResult.getStatus().toString()
            log.info stepResult.getRequestContent()
            log.info stepResult.getResponseContent()
        } 
}

Karel