teak
10 years agoContributor
Property Transfers and CDATA
Hi, I am trying to transfer a responce to a property.
<data contentType="text/plain; charset=UTF-8" contentLength="56"><![CDATA[access_token=674255899342123|OE_p68aK0XgY1rkGYRgkK-c_DIQ]]></data>
I want to transfer the access_token.
I have tried Response>XPath access_token:
Mon Oct 26 15:23:02 CET 2015 | temp_1 | [error: Unexpected element: CDATA] |
I have read this but am still a little confused and the example seems more complicated than what I am tring to achieve: http://www.soapui.org/functional-testing/working-with-cdata.html
Is there an easy way to extract the access_token?
Thanks,
Michael
I managed to get there eventually,
I used the groovy script to get the cdata and removed the string "access_token=" from it. I ended up with what I wanted in the end.
I'm not sure if this is a good practice though. I thought there maybe and easier way to get it.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) def response = context.expand('${GET access token#ResponseAsXml}') def holder = groovyUtils.getXmlHolder(response) node_data = holder.getNodeValue("//data") context.access_token = node_data.replaceAll("access_token=", ""); log.info context.access_token