【发布时间】:2015-03-19 15:25:26
【问题描述】:
我遇到了问题。
所以我得到了这样的 WSDL:
<node1>
<subnode1>data</subnode1>
<subnode2>data</subnode2>
<subnode3>data</subnode3>
<subnode4>data</subnode4>
<!--Zero or more repetitions:-->
<subnode5>
<subsubnode1>data</subsubnode1>
<subsubnode2>data</subsubnode2>
<subsubnode3>data</subsubnode3>
</subenode5>
</node1>
对于通过 SoapUI 进行的测试,现在的问题是,subnode5 可以有一个或多个 reptions,这取决于数据库。现在我的问题 - 如何解决这个问题以使重复动态化。
所以我尝试通过这样的 groovy 脚本附加 subnode5:
import com.eviware.soapui.support.XmlHolder;
import com.eviware.soapui.support.GroovyUtils;
def groovyUtil = new GroovyUtils( context )
def holder = groovyUtil.getXmlHolder( "name#Request" )
def parentnode = holder.getDomNode( "//node1" )
def text = '''
<subnode5>
<subsubnode1>data</subsubnode1>
<subsubnode2>data</subsubnode2>
<subsubnode3>data</subsubnode3>
</subnode5>
'''.stripMargin()
def nodetext = groovyUtil.getXMLHolder( text )
def nodeItem = nodetext.getDomNode ( "//subnode5")
parentnode.appendChild(nodeItem, true)
holder.updateProperty()
但我收到一条错误消息:
groovy.lang.MissingMethodException:没有方法签名:org.apache.xmlbeans.impl.store.Xobj$ElementXobj.appendChild() 适用于参数类型:(org.apache.xmlbeans.impl.store.Xobj$ ElementXobj, java.lang.Boolean) 值:[?xml version="1.0" encoding="UTF-8"?> , ...] 可能的解决方案:appendChild(org.w3c.dom.Node) 错误在第 29 行
我将在请求中添加一个新孩子
<node1>
<subnode1>data</subnode1>
<subnode2>data</subnode2>
<subnode3>data</subnode3>
<subnode4>data</subnode4>
<subnode5>
<subsubnode1>data</subsubnode1>
<subsubnode2>data</subsubnode2>
<subsubnode3>data</subsubnode3>
</subenode5>
--first repition--
<subnode5>
<subsubnode1>data</subsubnode1>
<subsubnode2>data</subsubnode2>
<subsubnode3>data</subsubnode3>
</subenode5>
--second repition--
<subnode5>
<subsubnode1>data</subsubnode1>
<subsubnode2>data</subsubnode2>
<subsubnode3>data</subsubnode3>
</subenode5>
.... and so on
</node1>
【问题讨论】:
标签: groovy soapui appendchild