Forum Discussion
Hi,
> How can i extract value from CDATA using query match dispatch style. so that i could make a mock Response.
This is not possible with the Query Match dispatching strategy. As per documentation (https://support.smartbear.com/readyapi/docs/servicev/configure/dispatch/query-match.html), Query Match extracts the info from the obtained request, compares the obtained result with the expected value and returns the response for which the comparison matches. And it is my understanding that you don't have a list of fixed expected values, do you?
You should use Script strategy instead (https://support.smartbear.com/readyapi/docs/servicev/configure/dispatch/script.html).
https://community.smartbear.com/t5/Service-Virtualization-Virtual/Extracting-value-from-requestBody-and-using-it-in-mockResponse/m-p/167877/highlight/false#M424 might help you with code.
(Also, https://community.smartbear.com/t5/Service-Virtualization-Virtual/ServiceV-Pro-Default-response-unexpectedly-replacing-the/td-p/167802 contains some useful code snippets as well.)
Does this help?
Hi Alex,
Thanx for your Update :)
My question is in script aslo how can i Parse xml from CDATA ? Is there any specific script for that. If it is can you help me on this?
- AlexKaras6 years agoChampion Level 3
> how can i Parse xml from CDATA ?
If you really need to parse, then you may create an instance of MSXML parser, load the content of the request into it and use appropriate methods to parse. (E.g.: https://msdn.microsoft.com/en-us/library/aa468547.aspx)
However, I consider this to be too difficult (sure, I have no idea about your project) and would suggest to consider XPath to extract the needed value from request body.
Related Content
Recent Discussions
- 4 days agominhng