SOAUI Groovy Getresponsenode.xml中的值为null
我遇到了一个问题,我尝试了不同的场景, 我是一名新的api服务自动化测试人员,我正在使用soapui和groovy来测试我的服务 问题是: 我有一个响应请求的服务,我想从响应中获得一个特定的数据/值。问题就从这里开始,因为我已经传递了变量的xpath及其值,但是当我在groovy脚本上打印日志时,它会打印一个空值 任何有类似问题的人能帮上忙吗?谢谢你 我的回答中重要的部分在哪里:SOAUI Groovy Getresponsenode.xml中的值为null,xml,groovy,soapui,web-api-testing,nodevalue,Xml,Groovy,Soapui,Web Api Testing,Nodevalue,我遇到了一个问题,我尝试了不同的场景, 我是一名新的api服务自动化测试人员,我正在使用soapui和groovy来测试我的服务 问题是: 我有一个响应请求的服务,我想从响应中获得一个特定的数据/值。问题就从这里开始,因为我已经传递了变量的xpath及其值,但是当我在groovy脚本上打印日志时,它会打印一个空值 任何有类似问题的人能帮上忙吗?谢谢你 我的回答中重要的部分在哪里: <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlso
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<ns0:outputMessage xmlns:ns0="urn://soa/es/Theater/GetBarProducts/Root">
<ns1:Header xmlns:ns1="http://xmlns.soa.com/SharedResources">
<ns1:timeout>14500</ns1:timeout>
<ns1:creationTime>2019-09-23T11:07:20+01:00</ns1:creationTime>
<ns1:iTrackingID>f7e8ea93-9736-4380-97ab-846b9cc69fbd</ns1:iTrackingID>
<ns1:eTrackingID>>f81c1210-88fa-4188-8358-b86825d5df70</ns1:eTrackingID>
<ns1:application>CINEMAS</ns1:application>
<ns1:user>APIQMS</ns1:user>
<ns1:process>GetBarProducts</ns1:process>
<shar:AccessData xmlns:data="urn://soa/es/Theater/GetBarProducts/Data" xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms" xmlns:ns0="http://xmlns.soa.com/SharedResources" xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:oas1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:root="urn://soa/es/Theater/GetBarProducts/Root" xmlns:shar="http://xmlns.soa.com/SharedResources" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<shar:userOS>os</shar:userOS>
<shar:remoteHost>host</shar:remoteHost>
<shar:remoteIP>ip</shar:remoteIP>
<shar:otherInfo>info</shar:otherInfo>
</shar:AccessData>
<ns0:Status xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms" xmlns:ns0="http://xmlns.soa.com/SharedResources">
<ns0:eCodes>
<ns0:eCode>COM-000</ns0:eCode>
<ns0:eDescription>Success</ns0:eDescription>
</ns0:eCodes>
<ns0:eNative>
<ns0:eCode>OK</ns0:eCode>
<ns0:eDescription/>
<ns0:eSystem>ArpuxNew</ns0:eSystem>
</ns0:eNative>
</ns0:Status>
</ns1:Header>
<ns1:DataOutput xmlns:ns1="urn://soa/es/Theater/GetBarProducts/Data">
<ns1:TheaterProducts>
<ns1:TheaterProduct Description="Menu_Pequeno" ID="C101" Price="5.4" Size="Pequeno" Type="Menu Pipocas" UUID="00aacfa5-8169-4e53-b315-ee9682461936">
<ns1:Group GroupID="App1" Name="Menus"/>
<ns1:SubGroup GroupID="App2" Name="Menu Clássico"/>
<ns1:Files>
<ns1:File Height="400" Path="//cdn.nos.pt/cinemas/products/files/400x400/null" Width="400"/>
<ns1:File Height="225" Path="//cdn.nos.pt/cinemas/products/files/225x225/null" Width="225"/>
<ns1:File Height="1000" Path="//cdn.nos.pt/cinemas/products/files/1000x1000/null" Width="1000"/>
</ns1:Files>
<ns1:TheaterProductItems>
<ns1:TheaterProductItem>
<ns1:TheaterProducts>
<ns1:TheaterProduct Description="Caixa Doce Pequena" ID="B028" Index="1" Size="Pequeno" Type="Doces" UUID="6fad59b3-b623-4f59-9fda-a25cf4cc2738">
<ns1:Group GroupID="02" Name="Pipocas"/>
</ns1:TheaterProduct>
<ns1:TheaterProduct Description="Caixa Sal Pequena" ID="B032" Index="2" Size="Pequeno" Type="Salgadas" UUID="4c69ead4-04a6-4413-9e21-bd25a9ab51ee">
<ns1:Group GroupID="02" Name="Pipocas"/>
</ns1:TheaterProduct>
<ns1:TheaterProduct Description="Caixa Mista Pequena" ID="B070" Index="3" Size="Pequeno" Type="Mistas" UUID="663f57b3-0534-4e75-9f41-fedbef008b4a">
<ns1:Group GroupID="02" Name="Pipocas"/>
</ns1:TheaterProduct>
</ns1:TheaterProducts>
</ns1:TheaterProductItem>
<ns1:TheaterProductItem>
<ns1:TheaterProducts>
情况是,我使用了这条线,它适用于不同的服务,但它在这里不起作用,它真的很有趣
这是一条在不同服务上工作的线路的证明:
以下是我对所需服务的回应:
如果有人知道任何解决方案或类似的东西,这将对我有很大帮助 XML需要定义名称空间并与每个节点关联。你的代码
def reqvalue1 = response.getNodeValue('//ns1:TheaterProduct[1]/@UUID')
使用名称空间ns1
,但是您没有定义它
对于只读操作,使用通配符命名空间是完全安全的,如下所示:
def reqvalue1 = response.getNodeValue('//*:TheaterProduct[1]/@UUID')
还请注意,SoapUI内部将所有内容都表示为XML。您可以在context.expand()行准备好节点值,以便:
def reqvalue1 = context.expand('${SOAP#Response#//*:TheaterProduct[1]/@UUID}')
SoapUI提供了一些附加信息。感谢@SiKing提供的帮助。由于名称空间的原因,我尝试了其他防御,其工作原理如下:def reqvalue6=response.getNodeValue('/:TheEartProduct[3]/@UUID'))log.info requvalue6->Wed Sep 25 12:15:21英国夏令时2019:info:663f57b3-0534-4e75-9f41-fedbef008b4a
def reqvalue1 = response.getNodeValue('//*:TheaterProduct[1]/@UUID')
def reqvalue1 = context.expand('${SOAP#Response#//*:TheaterProduct[1]/@UUID}')