简体   繁体   中英

groovy.lang.MissingMethodException: No signature of method in groovy script

Can some one please help me with the following code. It is causing "groovy.lang.MissingMethodException: No signature of method: java.lang.String.setNodeValue() is applicable for argument types: (java.lang.String, java.lang.String) values: [//ns:tem:intA, 50] error at line: 14" error.

def getaddresponse=context.expand('${Add SOAP Request#response}')

import com.eviware.soapui.support.XmlHolder

def addresponseholder= new XmlHolder(getaddresponse) 
addresponseholder.namespaces["ns"]="http://tempuri.org/"

def addresponsenodevalue=                  
    addresponseholder.getNodeValue("//ns:AddResult")

def deleterequest=context.expand('${Delete SOAP Request#request}')
def deleteholder =new XmlHolder (deleterequest)

deleteholder.namespaces["ns"]="http://tempuri.org/"
deleterequest.setNodeValue("//ns:tem:intA",addresponsenodevalue)

def updatedxml=deleterequest.getXml()

The problem is that context.expand(String content) returns a String , which by default does not have the method setNodeValue(String xpath, Object value) .

Try calling setNodeValue() on your deleteholder instead:

deleteholder.setNodeValue("//ns:tem:intA",addresponsenodevalue)
def updatedxml=deleteholder.getXml()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM