kbourdel
8 years agoOccasional Contributor
Script assertion using regex to get a value from the response header
Hello-
I have SoapUI NG & I'm attempting to extract one piece of info from the response header within an assertion script using regex, but I'm not getting the desired result.
Any guidance would be great!
The response header called 'WEBAPI_RESPONSE_DETAIL' contains the following:
{"ProcessingMilliseconds":1.34,"ResponseCount":1,"ProcessingMachine":"QAC1","ApplicationVersion":"2.1.766.10728","BuildNumber":"2.1.766.10728","EnvironmentName":"QA","MethodName":"/MemberStore/123/2.1/Routers/QualifiedQuotas"}
I'm only interested in the value for ProcessingMilliseconds (so in this example, 1.34).
My assertion script is the following:
def Details = messageExchange.responseHeaders["WEBAPI_RESPONSE_DETAIL"] log.info("Details: "+ Details) def regEx1 = ~/.*ProcessingMilliseconds":([0-9\.]*).*/ def sla = Details[0].replaceAll(regEx1,'') log.info("sla: " + sla)
When I run the assertion, I get nothing back.
Any ideas what I might be doing wrong?