我试图使用groovy获取属性 IntegratorCode 和 ProductType 的值。
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAPNYK1="http://www.w3.org/2001/XMLSchema"
xmlns:SOAPNYK2="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAPNYK3="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Header>
<Authentication
xmlns="urn:iQQ:API:22:iQQMessages.xsd" EmployeeCode="*****" IntegratorCode="GENERIC" Pwd="******" Usr="SYSUSER"/>
</soap:Header>
<soap:Body>
<CanOfferProduct
xmlns="urn:iQQ:API:22:iQQMessages.xsd">
<OnQuotePackage
xmlns="" ProductType="GAP" QuoteNumber="74859">test
</OnQuotePackage>/>
</CanOfferProduct>
</soap:Body>
</soap:Envelope>
我使用XmlSlurpur尝试了以下方法
def result = new XmlSlurper().parseText(xml)
println(result.Envelope.Header[1].Authentication.@IntegratorCode)
//output = IntegratorCode
我想打印IntegratorCode的值为“ GENERIC”。 我不确定在这种情况下我做错了什么。请帮忙。
答案 0 :(得分:1)
您所说的结果 是 soap:Envelope ,因此,您实际上有了Envelope.Envelope ...这可以起作用:
Server.Transfer("Privacy");
作为预防措施,我通常按以下方式使用它:
println result.Header.Authentication.@IntegratorCode