【发布时间】:2020-05-25 15:31:02
【问题描述】:
我试图在查询参数的 xpath 匹配中添加 AND 条件,但它不起作用。
我正在创建多个存根,其中 uniqueId 可以包含同样的数字 00000 或 11111,但 serviceName 会有所不同。例如,在第一个请求中,uniqueId 为 1000001 且 serviceName='ABC',在第二个请求中,uniqueId 再次为 1000001 且 serviceName 为 'XYZ'。因为这两种反应会有所不同。我创建了三个存根,一个用于服务 ABC,第二个用于服务 XYZ,第三个是默认的,没有和 xpath 匹配。 当我使用包含 uniqueId 1000001 和 serviceName ABC 或 XYZ 的查询参数调用服务时,每次我得到默认存根的响应。 在查询参数中传递 xml
"queryParameters":{
"xmlreqdoc": {
"matchesXPath" : "//*[[local-name()='uniqueId'][text()[contains(.,'00000')]] AND //*[local-name()='serviceName'][text() = 'ABCDEFGH']]"
}
}
我已经创建了具有优先级的存根.. 并且似乎每次都返回默认值。以下是请求xml
<?xml version="1.0" encoding="UTF-8"?>
<service>
<serviceHeader>
<userId>XXXX</userId>
<password>XXXXX</password>
<serviceName>ABCDEFGH</serviceName>
</serviceHeader>
<serviceBody>
<subServiceName>add</subServiceName>
<uniqueId>00000</uniqueId>
</serviceBody>
</service>
下面是我创建的存根映射
{
"priority" : 1,
"request": {
"urlPath": "/testMappings",
"method": "GET",
"headers": {
"Content-Type": {
"equalTo": "application/xml"
},
"Accept": {
"equalTo": "application/xml"
}
},
"queryParameters":{
"xmlreqdoc": {
"matchesXPath" : "//*[//[local-name()='uniqueId'][text()[contains(.,'00000')]] AND //*[local-name()='serviceName'][text() = 'ABCDEFGH']]"
}
}
},
"response": {
"status": 400,
"headers": {
"Content-Type" : "application/xml"
},
"fixedDelayMilliseconds": 500,
"bodyFileName": "ERROR.xml"
}
}
任何帮助或指示将不胜感激。提前致谢!!
【问题讨论】: