2016-07-24 42 views
0

我有這個soap響應,我需要獲取標記platformMessage的值我寫了一個xpath查詢,但它不起作用,檢查jmeter中的日誌文件告訴我這個「前綴必須解析到一個命名空間:NS2" ,繼承人的XPath查詢如何從soap響應jmeter中檢索值

/S:Envelope[@xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"]/S:Body/ns2:activateProductResponse[@xmlns:ns2="http://ws.business.api.fulfillmentengine.com/"]/return/platformMessage 

繼承人的XML

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> 
    <S:Body> 
     <ns2:activateProductResponse xmlns:ns2="http://ws.business.api.fulfillmentengine.millicom.com/"> 
     <return> 
      <platformCode>1</platformCode> 
      <platformMessage>Fail operation.El set-top box ya existe. Code Response:|22098: 22098: 1</platformMessage> 
      <responseCode>13</responseCode> 
      <responseMessage>Error executing action in platforn</responseMessage> 
      <UUID>3cb49b29-513e-11e6-b5db-005056807f0c</UUID> 
      <platformName>INTRAWAY</platformName> 
     </return> 
     </ns2:activateProductResponse> 
    </S:Body> 
</S:Envelope> 

回答

0

使用@xmlns:因爲儘管出場命名空間是不一樣的NS2中的XPath無效屬性。

如果啓用「使用名稱空間」,那麼下面的XPath應該工作:

/S:Envelope/S:Body/ns2:activateProductResponse/return/platformMessage 

或者,如果你想有一個骯髒的(慢)的解決方法,你可以參考一下,像這樣的節點名稱:

/*[local-name()='Envelope']/*[local-name()='Body']/*/[local-name()='activateProductResponse]/return/platformMessage 
0

你應該閱讀:

特別注意:

作爲工作輪上它是基於JMeter的在Xalan的XPath的解析器實現的命名空間的限制,你可以提供一個屬性文件其中包含名稱空間前綴的映射: prefix1 =完整命名空間1 prefix2 =完整命名空間2 ... 您可以使用pro在jmeter.properties文件中引用此文件perty:

  • xpath.namespace.config

查找範圍jmeter.properties該物業,一切都解釋清楚