0

我正在尝试从 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 总是给我空值。我尝试了以下选项 -

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
4

2 回答 2

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>
    
于 2013-06-22T21:25:04.330 回答
0

您的第三个答案是最接近的,但/ns9:quoteResponse/中间缺少完整的答案。

于 2013-06-21T21:40:06.783 回答