Forum Discussion

M_McDonald's avatar
M_McDonald
Super Contributor
15 years ago

How to get expanded values in RequestFilter.afterRequest event

Hi -

Request properties retrieved with request.getPropertyValue() in the RequestFilter.afterRequest event are not expanded. Is this the expected behavior?

Thanks.

6 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    hmm.. how do you mean? Can you show some code?

    regards!

    /Ole
    eviware.com
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Sure. The following code in the event:

     def value = request.getProperty("Value").value

    xmlResult = """<resultset>
      <property name="Value">${value}</property>
            </resultset>"""

    context.httpResponse.responseContent = xmlResult


    results in this reponse:

    [tt:2xxc5tjj]
      ${#TestCase#Value}
    [/tt:2xxc5tjj]

    I know I can wrap this in a context.expand(), but I would think that the value would have already been expanded for the request to be submitted.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    hmm.. I don't get the whole picture here.. what is the request object? (as far as I know the request object in soapUI doesn't have a getProperty(..) method)

    Do you want to get some content from the actual sent request?

    regards!

    /Ole
    eviware.com
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    The code I had for this in a MockService used mockRequest.httpRequest.getQueryString() and then parsed that.

    I didn't see an equivalent method for the event request but I noticed that request.getProperty() would get me (hardcoded) query parameters, but this didn't work for a query parameter that uses a property expansion.

    See attached project.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    ah!

    sorry.. i was thinking soap-requests.. gotta have more modern thoughts.. :-)

    Yes, you will have to do the property-expansion yourself with the context.expand(..), these methods will just give you whatever is typed into the parameter value..

    regards!

    /Ole
    eviware.com