【发布时间】:2020-02-04 06:41:14
【问题描述】:
我正在尝试使用 SOAPUI 工具中的 groovy 脚本替换我现有的肥皂信封中的一些节点 下面是我的包装盒
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<o:Security s:mustUnderstand="0" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>2019-11-28T08:18:33.396Z</u:Created>
<u:Expires>2019-11-28T08:23:33.396Z</u:Expires>
</u:Timestamp>
</o:Security>
</s:Header>
<s:Body>
<ViewUserResponse xmlns="urn:myapp-com:Security.2014.pop.service.operation1">
<ViewUserResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<LoginID xmlns:a="urn:myapp-com:Security.2012.pop.service.operation2">
<a:IDType>
<a:ID>pop</a:ID>
<a:Type>UserName</a:Type>
</a:IDType>
<a:IDType>
<a:ID>pop@we.com</a:ID>
<a:Type>email</a:Type>
</a:IDType>
</LoginID>
<Address xmlns:a="urn:myapp-com:Security.2012.pop.service.operation2">
<a:City>MH</a:City>
<a:State>IND</a:State>
<a:Pincode>1234</a:Pincode>
</Address>
.
.
.
我尝试用新内容替换 LoginID 部分,新内容是
<a:IDType>
<a:ID>pop_new</a:ID>
<a:Type>UserName</a:Type>
</a:IDType>
<a:IDType>
<a:ID>pop_new@we.com</a:ID>
<a:Type>email</a:Type>
</a:IDType>
下面是我的代码
def g = new XmlSlurper(false,false).parseText(newXml).declareNamespace(a:'urn:myapp-com:Security.2012.pop.service.operation2');
existingXml.LoginID.replaceBody(g)
这会引发错误 org.xml.sax.SAXParseException;行号:2;列号:137;元素“a:IDType”的前缀“a”未绑定。
【问题讨论】:
标签: groovy soapui xmlslurper