cancel
Showing results for 
Search instead for 
Did you mean: 

GETTING ERROR WHEN USING getDomNodes()

SOLVED
Occasional Contributor

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"
  }
}

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: GETTING ERROR WHEN USING getDomNodes()

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

 

 

7 REPLIES 7
Community Hero

Re: GETTING ERROR WHEN USING getDomNodes()

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"
Occasional Contributor

Re: GETTING ERROR WHEN USING getDomNodes()

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

Community Hero

Re: GETTING ERROR WHEN USING getDomNodes()

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
Occasional Contributor

Re: GETTING ERROR WHEN USING getDomNodes()

Ya. This would be fine. I haven't thought like this. Thank you I will check now.

Occasional Contributor

Re: GETTING ERROR WHEN USING getDomNodes()

My JDBC response is like below

<Results>
<ResultSet fetchSize="10">
<Row rowNumber="1">
<V_OBJ_ID>6455a073-29b0-4261-a310-a99b89ef57bb</V_OBJ_ID>
<V_OBJ_CODE>TEST_TYPE_5</V_OBJ_CODE>
<N_VERSION>1</N_VERSION>
<V_AUTH_STATUS>D</V_AUTH_STATUS>
</Row>
</ResultSet>
</Results>

 

 

But when I use 

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

assert DBholder.V_OBJ_ID == json.payload.id

 

I am getting the below error. there is no value for DBholder.V_OBJ_ID 

com.eviware.soapui.support.XmlHolder@66fa28 (toString() threw java.lang.NullPointerException) error at line: 27

Community Hero

Re: GETTING ERROR WHEN USING getDomNodes()

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

 

 

Occasional Contributor

Re: GETTING ERROR WHEN USING getDomNodes()

but the actual question why the below error
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

 

when will we use [//*]

New Here?
Join us and watch the welcome video:
Join the exciting event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win