Forum Discussion
atts
17 years agoOccasional Contributor
So here's my solution in case someone else needs to do something similar.
Not saying this is the best way - I hope there's a much simpler way, if so please feel free to update this post ;-)
My first HTTP request returns the following;
746223053
0
AAABIy4kyFzg69MSRQHUa4Mzy9vsxkzTKj29HCbg3AMpYj8QOvhuIqdMncTIlvQ8GC2Y07JaTFfdxq4oE9rs5A==
I want to extract the token string "AAA...." and feed it into subsequent HTTP/SOAP requests.
My test steps are ordered as follows;
Properties etc
...
SOAP Request
HTTP Request <--- Returns a token
Groovy Script <--- Extract the token string, and set a Property value.
Property Transfer <---- Transfer the property to next HTTP request.
HTTP Request <---- Uses token from previous request.
SOAP Requsts
...
The Groovy script used is as follows;
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def httpResponse = context.testCase.testSteps["signOnByMACAddress"].testRequest.response.responseContent
def REGEX = /"token":"(.*)"/
def token = (httpResponse =~ REGEX)
groovyUtils.setPropertyValue("Properties", "Token", token[0][1])
cheers;
Not saying this is the best way - I hope there's a much simpler way, if so please feel free to update this post ;-)
My first HTTP request returns the following;
I want to extract the token string "AAA...." and feed it into subsequent HTTP/SOAP requests.
My test steps are ordered as follows;
Properties etc
...
SOAP Request
HTTP Request <--- Returns a token
Groovy Script <--- Extract the token string, and set a Property value.
Property Transfer <---- Transfer the property to next HTTP request.
HTTP Request <---- Uses token from previous request.
SOAP Requsts
...
The Groovy script used is as follows;
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def httpResponse = context.testCase.testSteps["signOnByMACAddress"].testRequest.response.responseContent
def REGEX = /"token":"(.*)"/
def token = (httpResponse =~ REGEX)
groovyUtils.setPropertyValue("Properties", "Token", token[0][1])
cheers;