我尝试使用带有XmlHolder
方法的getDomNodes
类以XML格式访问我的请求的所有节点,当我尝试它时会收到此错误。
有人可以解释这是什么意思吗?
我的源代码:
import com.eviware.soapui.support.XmlHolder
log.info "hello !! welcome to "
def holder = new XmlHolder(context.expand('${logIn - Request 1#request}')
def allnodes = holder.getDomNodes("//LoginParameters_1")
我得到的错误:
org.codehaus.groovy.control.MultipleCompilationErrorsException:启动失败:Script15.groovy:6:意外令牌:def @ line 6,第1列.def allnodes = holder.getDomNodes(" // LoginParameters_1"抛出org.apache.xmlbeans.XmlException ^ org.codehaus.groovy.syntax.SyntaxException:意外令牌:def @ line 6,第1列。在org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:140)在org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:108)org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236)org.codehaus.groovy.control.CompilationUnit $ 1。调用(CompilationUnit.java:162)org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912)org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574)org.codehaus .groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)...
import com.eviware.soapui.support.XmlHolder import com.eviware.soapui.support.xml.XmlUtils
log.info "hello !! welcome to " xmlu= new XmlUtils()
holder= new XmlHolder(context.expand('${logIn - Request 1#request}'))
i=0
for (nodes in holder.getDomNodes("//wsos:logIn")) { if(xmlu.getNodeValue(nodes[i])=="?")
xmlu.setNodeValue(nodes[i],"")
i++;
}
给我以下错误: groovy.lang.MissingMethodException:没有方法签名:org.apache.xmlbeans.impl.store.Xobj $ ElementXobj.getAt()适用于参数类型:(java.lang.Integer)values:[0]可能的解决方案:getAt (java.lang.String),item(int),putAt(java.lang.String,java.lang.Object),wait(),grep(),getClass()错误在行:16
答案 0 :(得分:0)
org.codehaus.groovy.syntax.SyntaxException
与代码中的语法不正确有关,在您的具体情况下,问题是缺少闭括号:
关闭)
声明时缺少XmlHolder
:
def holder = new XmlHolder(context.expand('${logIn - Request 1#request}')
必须:
def holder = new XmlHolder(context.expand('${logIn - Request 1#request}'))
^ missing close