在执行我收到错误即groovy.lang.MissingPropertyException脚本:没有这样的属性:客户ID类Groovy脚本错误没有这样的属性:客户ID为
脚本
import org.w3c.dom.Node
import org.w3c.dom.NodeList
NodeList nodes = employeeServiceResponse.getFirstChild().getChildNodes()
String firstName = null
String lastName = null
for (int i = 0 i < nodes.getLength() i++) {
Node node = nodes.item(i)
if ("firstName".equals(node.getLocalName()))
firstName = node.getFirstChild().getNodeValue()
else if ("lastName".equals(node.getLocalName()))
lastName = node.getFirstChild().getNodeValue()
}
if (firstName != null && lastName != null){
println 'Found employee: ' + firstName + ' ' + lastName
discountPercent = 10
return true
} else {
println 'Employee not found: ' + customerId
discountPercent = 0
return false
}
我新的常规脚本可以请任何人帮助我。脚本解析数据。
你可以举一些例子的XML?你是如何创建'employeeServiceResponse'? –