org.xml.sax.SAXParseException在groovy脚本中未绑定元素“ a:IDType”的前缀“ a”

问题描述 投票:0回答:1

我正在尝试使用SOAPUI工具中的常规脚本替换现有肥皂包中的某些节点下面是我的信封[]

<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>[email protected]</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>[email protected]</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; lineNumber:2; columnNumber:137;没有绑定元素“ a:IDType”的前缀“ a”。

我正在尝试使用SOAPUI工具中的groovy脚本替换现有肥皂包中的某些节点,下面是我的信封

groovy soapui xmlslurper
1个回答
0
投票

我无法猜测您为什么会出错,因为您没有共享完整的代码。

© www.soinside.com 2019 - 2024. All rights reserved.