Ask a Question

Property Transfers and CDATA

SOLVED
teak
Contributor

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 2015temp_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

 

1 REPLY 1
teak
Contributor

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

 

cancel
Showing results for 
Search instead for 
Did you mean: