Forum Discussion

Jibu's avatar
Jibu
Occasional Contributor
6 years ago

GETTING ERROR WHEN USING getDomNodes()

def json = new JsonSlurper().parseText(response)
def groovyutils = new com.eviware.soapui.support.GroovyUtils(context)

def DBholder = groovyutils.getXmlHolder("JDBC RequestForDatabase#ResponseAsXml")

def xmlUtil = new com.eviware.soapui.support.xml.XmlUtils();

def nodes = json.getDomNodes("//*");   (line 28)

 

Getting the below exception when runing scripts

 

groovy.lang.MissingMethodException: No signature of method: groovy.json.internal.LazyMap.getDomNodes() is applicable for argument types: (java.lang.String) values: [//*] error at line: 28

 

 

 

My response JSON is like below

 

{
  "payload": {
    "authstatus": "string",
    "code": "string",
    "id": "string",
    "action_code": "string"
  }
}

 

  • Sorry, I had forgotten that XmlHolder is based on XPath. So it would be more like this:

     

    assert DBholder["/Results/ResultSet/Row[@rowNumber=1]/V_OBJ_ID"] == json.payload.id

     

     

  • JHunt's avatar
    JHunt
    Community Hero

    What are you trying to achieve with this script?

     

    After the first line, you can just get the fields directly.

    def json = new JsonSlurper().parseText(response)
    assert json.payload.authstatus == "string"
    • Jibu's avatar
      Jibu
      Occasional Contributor

      I am trying to read each node in response and I have an JDBC xmlresponse ready. So I want to compare the response payload with each tag of the jdbc xml and then insert to an excel after comparing the data

      • JHunt's avatar
        JHunt
        Community Hero

        Ok, so I think this is all you need, right?

         

        def json = new JsonSlurper().parseText(response)
        def groovyutils = new com.eviware.soapui.support.GroovyUtils(context)
        def DBholder = groovyutils.getXmlHolder("JDBC RequestForDatabase#ResponseAsXml")

        assert DBholder.foo == json.payload.foo
        assert DBholder.bar == json.payload.bar