Forum Discussion
3 Replies
Sort By
- sadikaContributoryou can get Json String from Response using below Groovy Script
import com.eviware.soapui.support.XmlHolder
import net.sf.*;
import net.sf.json.*;
import net.sf.json.groovy.*;
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
//Getting response from methods
def ResponseMessage = testRunner.testCase.testSteps["TestStepName"].testRequest.response.contentAsString
def jsonresponse = new XmlHolder(ResponseMessage)
def resonseBody = jsonresponse .prettyXml
Regards,
Sadik Ali - EswarJNew ContributorHi..
You can also get the values using Xpath in a property transfer step.
Though the response is in JSON format, SoapUI allows you to view the response in XML format as well.
Click on the XML tab in the response window to view this in XML.
In the property transfer step, choose the appropriate test step as source and in the drop down property choose responseAsXml.
-Eswar - KeyofSea123ContributorSadik Ali,
I'm trying to use the technique that you gave. It's mostly working but I'm getting a CDATA error on the XmlHolder line. I'm not new to SoapUI but I'm pretty new to Groovy. I have some programming experience but this is a new language to me.
Can you please offer some advice?
Thanks,
Trish
Related Content
Recent Discussions
- 4 days agoemoya