【发布时间】:2019-12-19 17:26:17
【问题描述】:
这是请求的样子:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
...
<SOAP-ENV:Header>
<ns2:Security SOAP-ENV:mustUnderstand="1">
<ns2:UsernameToken>
...
</ns2:UsernameToken>
</ns2:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:customerQualificationRequest>
<ns1:header>
...
</ns1:header>
<ns1:creditApplication>
...
<ns1:lastName>Shopping</ns1:lastName>
...
</ns1:creditApplication>
</ns1:customerQualificationRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
还有模拟:
Scenario: pathMatches('<path>') && requestHeaders['SOAPAction'][0] == '<soapAction>' && bodyPath('/ns1:customerQualificationRequest/ns1:creditApplication/ns1:lastName') == 'Shopping'
如果我只删除 bodyPath,但找不到与 bodyPath 匹配的内容,它会起作用。我需要有几个 lastName 不同的情况,因为答案会不同,所以我需要匹配那个参数。 我做错了什么?
【问题讨论】:
-
bodyPath('//ns1:customerQualificationRequest/ns1:creditApplication/ns1:lastName')可以通过选择所有customerQualificationRequest标记来工作,无论它们在 XML 文档中的什么位置。指定从根开始的具体路径 -/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:customerQualificationRequest/ns1:creditApplication/ns1:lastName- 是一种“更安全”的方式。不过,在这两种情况下,都必须有一种方法可以为标签前缀(ns1、SOAP-ENV)指定命名空间(xmlns)