Forum Discussion

mmoser18's avatar
mmoser18
Frequent Contributor
8 years ago
Solved

How to access the request's endpoint in a scripted assertion?

In my soapUI project I am making heavy use of scripted assertions, i.e. I am constructing the strings against which to match the responses using Groovy scripts.

Some of our calls echo a "self-link", i.e. the contain a link that was used to request that message.

 

To generate the corresponding fraction of the comparison string I thus need the string from the "Endpoint" field in the request "form". That String is also contained in the "REST TestRequest Properties" tab as "Endpoint". How can I access this field as placeholder in a Groovy-String?

 

I tried using "${#TestRequest#Endpoint}" and "${#TestStep#Endpoint}" but these don't work. What would be the correct property designator for this "REST TestRequest"?

 

Hope I could make myself clear...

Michael

 

  • Hi Michael,

     

    Does something like this work for you?

     

    messageExchange.modelItem.testStep.httpRequest.endpoint

    Regards,

    Rupert

  • mmoser18, rupert_anderson has already provided answer.

    And here is another simple way to get the same in Script Assertion:

    context.endpoint

3 Replies

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi Michael,

     

    Does something like this work for you?

     

    messageExchange.modelItem.testStep.httpRequest.endpoint

    Regards,

    Rupert

  • nmrao's avatar
    nmrao
    Champion Level 3

    mmoser18, rupert_anderson has already provided answer.

    And here is another simple way to get the same in Script Assertion:

    context.endpoint

    • mmoser18's avatar
      mmoser18
      Frequent Contributor

      Yes - that did the trick! Thanks!

       

      I'm having another issue now where the replace(...)-method doesn't replace a substring as expected, but I guess Ill open a different thread for this.

       

      Cheers,

      Michael