Using Extension Tool to capture the request code
I have an instance where I need to capture the incoming request, and find part of the code marked by an unique identifier and return it as my request for my responders. How can I code this effectively?
Here is the code I have so far that I got from another application, but not sure if it works in Virtualize:
function setRequest()
{
MyRequest = context.incomingRequest("lisa.Listen.rsp");
MyNewRequest = ""; if (MyRequest!=null && MyRequest.indexOf("CDATA")>0){ MyNewRequest = MyRequest.substring(MyRequest.indexOf("CDATA[")+6,MyRequest.indexOf("]]")); return MyNewRequest; }else { return MyRequest; }
}
Comments
-
Hi,
It looks like that code is searching for the first text in an xml document that is wrapped in CDATA and returning the text value without the CDATA wrapper. I wonder if it might be simpler to just use a data bank to extract the text from the desired xml node. Do you know what field in the request that code would find?0 -
That part of the xml code will contain the entire xml request that is needed for the responders
0 -
Hi,
Is the initial request also xml? You might be able to use something like an XML Transformer chained to the incoming request to extract the "payload" text from the initial payload and return the contents as xml.0 -
correct, the overarching request is also xml. It just has a field within that contains the request code that I need for the response
0 -
So if I use the XML transformer and extract that element, will it be used as the request for my responders?
0 -
Hi,
It can be, there is an option under the "Misc" tab of the responder in "Request Handling" that says "Allow incoming request tools to modify the message"
Or you can chain tools directly to the output of the XML transformer to act on the output directly, e.g. data banks. Which one works best will depend on your responders situation: data source correlation vs data banking.
0