2013-06-21 34 views
0

我试图从下面的XML中检索数据,但我尝试的所有选项都给我空值。有人可以帮助!JMeter XPath Extractor问题

<?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的提取总是给我空值。 我曾尝试下面的选项 -

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

你的第三个答案是最接近的,但它是在中间缺少/ns9:quoteResponse/完成。

+0

我不好,这是笔误,而发布,甚至与标签它给了我Null值:( – Akshay

+0

然后,我不明白为什么该项目没有被找到我建议你检查你的名字空间绑定表达式中使用的前缀。祝你好运! –

+0

只是添加更多我得到下面异常当我尝试第三选项。断言失败消息:前缀必须解析为名称空间:ns8 – Akshay

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> 
    
+0

感谢您的建议,我遵循了所有步骤,但无法解决问题。命名空间对其他标签只有失败:( – Akshay

+0

显示你为命名空间设置的配置)工作正常吗? –

+0

感谢PMD,我忘了发布,不知何故它开始使用第三个选项,我把我的问题。 谢谢你的帮助!!! – Akshay