Forum Discussion
Hi, nmrao. I watched the video, and he is injecting properties into the response in a similar way that we're doing it. I believe his code has a similar vulnerability that we have - it's possible for two clients to get the same value in a response from his virtual service, but his intention was for each response to be random.
- swalchemist3 years agoOccasional Contributor
This is not working when I use this as a response:
mode="${=def clientId = mockRequest.getRequestHeaders().get("myClientId").get(0); context.expand("#MockService#" + clientId + "-mode")}'"
The problem is that "mockRequest" is not made available to code that is injected in a response like this (only in code in the script pane). Is there any way to read the request headers from code in the response?
We have some code in another response that modifies dates - this is working fine.
Other ideas on how to maintain state for multiple users of the virtual service is welcome. That state will affect the content of the responses.
- nmrao3 years agoChampion Level 3Not sure I understand.
Is it that a value from request needs to be into the response?
Are you working with SOAP or REST?- swalchemist3 years agoOccasional Contributor
Basically, yes. It's a bit more complex - a value in the request header will be used by the code to determine which property to include in the response. But if I can figure out how to reliably echo back a request header in the response, then I can figure out the rest.
I'm virtualizing an xmlrpc service, which I'm treating as a REST service in ReadyAPI. The sample response using the "${= }" syntax I gave in the last message is in the Response -> Edit pane on the outgoing response.
Related Content
- 6 years agoKarelHusa