Service Virtualization

Expand all | Collapse all

How to evaluate {{=expressions}} in transient response before it goes to custom data handler?

  • 1.  How to evaluate {{=expressions}} in transient response before it goes to custom data handler?

    Posted Apr 04, 2018 03:16 PM

    Hi,

     

    I am creating a custom data protocol. My transient response is an xml that has some expressions in it like this: {{=expression}}. In my custom data protocol, I am converting that xml into a message. When I try to update the transient response  I get an error because the expressions are not evaluated at the time of the response update as my program doesn't recognize {{=expression}}.

     

    How can I overcome this problem?

     

    Regards,

    Saman



  • 2.  Re: How to evaluate {{=expressions}} in transient response before it goes to custom data handler?
    Best Answer

    Broadcom Employee
    Posted Apr 04, 2018 03:45 PM

    I think you want to use testExec.parseInState() to force all expressions to be evaluated.



  • 3.  Re: How to evaluate {{=expressions}} in transient response before it goes to custom data handler?

    Posted Apr 04, 2018 04:09 PM

    Thanks much it worked!



  • 4.  Re: How to evaluate {{=expressions}} in transient response before it goes to custom data handler?

    Broadcom Employee
    Posted Apr 04, 2018 03:46 PM

    Hi Saman,

     

    Try this:

     

       String newBody = testExec.parseInState(oldBody);

     

    --Mike



  • 5.  Re: How to evaluate {{=expressions}} in transient response before it goes to custom data handler?

    Posted Apr 04, 2018 04:10 PM

    Thanks much. I tried below code:

     

    public void updateResponse(TestExec testExec, TransientResponse transientResponse){


    String xmlString = testExec.parseInState(transientResponse.getBodyAsString());

    ......

    }

     

    and it worked.