messageExchange does not exist in a Groovy script step. It works in Script assertion because the step the assertion is attached to does have request/responses. But in a Groovy script step, there is no request/response associated with the Groovy script itself.
You second script looks better where you look at the response of a particular steps. But I think you are creating too many objects. I'd put in a lot of "log.info" callouts to confirm on what happens. And by briefly looking at your script, you should at least change a line to:
def json = slurper.parseText response.xml
As in your case "response" is a XML placeholder object and not a string.
Thanks,
Michael Giller
SmartBear Software