Forum Discussion

JanPot's avatar
JanPot
Occasional Contributor
8 years ago

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

  • 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

     

  • KarelHusa's avatar
    KarelHusa
    Champion Level 1

    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

     

    • JanPot's avatar
      JanPot
      Occasional Contributor

      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

      • KarelHusa's avatar
        KarelHusa
        Champion Level 1

        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