我正在尝试从下面的XML中检索数据,但我尝试的所有选项都给了我null值。有人可以帮忙!!!
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns8:SearchQuoteResponse
xmlns="http://services.akshay.com/pr/search" xmlns:ns2="http://services.akshay.com/pr/po"
xmlns:ns3="http://services.akshay.com/pr/common"
xmlns:ns4="http://services.akshay.com/pr/fault"
xmlns:ns5="http://services.akshay.com/pr/appointment"
xmlns:ns6="http://services.akshay.com/pr/registration"
xmlns:ns7="http://services.akshay.com/pr/in"
xmlns:ns8="http://services.akshay.com/Services/ws"
xmlns:ns9="http://services.akshay.com/pr/q">
<ns8:responseType>SUCCESS</ns8:responseType>
<ns8:message>Quote Search completed successfully.</ns8:message>
<ns9:Quote>
<ns9:quoteId>72620</ns9:quoteId>
<ns9:quoteResponse>
<ns9:quoteExpiryDate>2013-08-04T10:17:35.000Z</ns9:quoteExpiryDate>
<ns9:listQuoteItemResponse>
<ns9:respQuoteItemId>657222</ns9:respQuoteItemId>
<ns9:lineNumber>1</ns9:lineNumber>
<ns9:afterMarketPartDetails>
<ns3:warrantyType />
</ns9:afterMarketPartDetails>
<ns9:listPrice>153.0</ns9:listPrice>
<ns9:netPrice>61.2</ns9:netPrice>
<ns9:partAvailability>IN</ns9:partAvailability>
<ns9:shippable>Y</ns9:shippable>
</ns9:listQuoteItemResponse>
</ns9:quoteResponse>
<ns9:createdDate>2013-06-20T16:17:34.996Z</ns9:createdDate>
</ns9:Quote>
</ns8:SearchQuoteResponse>
</S:Body>
</S:Envelope>
从上面的SOAP我需要<ns9:respQuoteItemId></ns9:respQuoteItemId>
标签的值,但XPath Extractor总是给我null值。
我试过以下选项 -
1 - //*[local-name()="respQuoteItemId"]/text()
2 - //*[local-name()='respQuoteItemId' and namespace-uri()='http://services.myportal.com/procurement/q']
3 - //ns8:SearchQuoteResponse/ns9:Quote/ns9:quoteResponse/ns9:listQuoteItemResponse/ns9:respQuoteItemId
答案 0 :(得分:1)
阅读本文:
http://jmeter.apache.org/usermanual/component_reference.html#XPath_Assertion
To overcome Xalan XPath parser implementation on which JMeter is based, you can
help the parsing by providing a Properties file which will contain:
- prefix1=Full Namespace 1
- prefix2=Full Namespace 2
...
You reference this file in user.properties file using the property:
- xpath.namespace.config=<path to your properties file>
答案 1 :(得分:0)
你的第三个答案是最接近的答案,但在中间缺少/ns9:quoteResponse/
才能完成。