cancel
Showing results for 
Search instead for 
Did you mean: 

How to Extract value from CDATA

Occasional Contributor

How to Extract value from CDATA

Let me explain my scenarion first. I have Request and Response . Both are having CDATA. While doing virtualization in ServiceV PRO I need to extract some specific value from Request so that i could set a condition to dispatch a response. Here is my question, How can i extract value from CDATA using query match dispatch style. so that i could make a mock Response. I'm awaiting for reply.
3 REPLIES
Community Hero

Re: How to Extract value from CDATA

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-... might help you with code.

(Also, https://community.smartbear.com/t5/Service-Virtualization-Virtual/ServiceV-Pro-Default-response-unex... contains some useful code snippets as well.)

 

Does this help?

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Occasional Contributor

Re: How to Extract value from CDATA

Hi Alex,

Thanx for your Update Smiley Happy

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?

Highlighted
Community Hero

Re: How to Extract value from CDATA

> 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.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Share Your Stories
Read Latest News