1
我嘗試使用groovy(SoapUI)創建以下XML。如何使用groovy將xsi名稱空間前綴添加到xml
預期的XML
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:save xmlns:ns2="http://service.generic.abc.it">
<arg1 xsi:type="ns4:ContractGroup" xmlns:ns4="http://generic.abc.it" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<discounts xsi:type="ns4:DiscountPrice"></discounts>
</arg1>
</ns2:save>
</S:Body>
</S:Envelope>
使用的代碼:(沒有工作)
def grUtils = new com.eviware.soapui.support.GroovyUtils(context)
// create XmlHolder for request
def requestHolder = grUtils.getXmlHolder("Contract_save#Request")
// find the Node that I am interested in
def requestNodeMain = requestHolder.getDomNode("//*:Body/*:save/*:arg1[1]")
// the Document object is used to create new nodes
def requestDocMain = requestNodeMain.getOwnerDocument()
def WideSearchRQElement = requestDocMain.createElementNS("ns4:DiscountPrice","type:discounts")
requestNodeMain.appendChild(WideSearchRQElement)
requestHolder.updateProperty(true)
您是否嘗試過給定的解決方案,看看是否有幫助? – Rao