2017-08-15 157 views
0

我從使用HP LoadRunner 12.53進行測試得到此SOAP響應。我需要提取的值可以不斷得到「沒有找到任何相符的特定查詢」使用lr_xml_get_values功能:lr_xml_get_value函數失敗

lr_xml_extract("XML={RESPONSE}", 
     "XMLFragmentParam=OutputParam", 
     "Query=/Envelope/Body/TimeExpenseAcknowledgmentCBM/RequestID/text()", 
     LAST); 

這裏是我的迴應:

"RESPONSE" = "<?xml version="1.0" encoding="utf-8"?> 
<soapenv:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soapenv:Body> 
    <timeexpresp:TimeExpenseAcknowledgmentCBM xmlns:timeexpresp="http://esoa.census.gov/soa/CanonicalModel/Core/CDM/TimeExpenseCDM/V1"> 
     <meta:RequestID xmlns:meta="http://esoa.census.gov/soa/CanonicalModel/Core/Common/V1">**N53e79c17.N60c0f9d8.7.15de03dae49.N3fbe**</meta:RequestID> 
    </timeexpresp:TimeExpenseAcknowledgmentCBM> 
    </soapenv:Body> 
</soapenv:Envelope>" 

我需要提取的RequestID值在**大膽**任何幫助??

+0

道歉 - 我的意思是添加此功能爲我的問題: \t \t lr_xml_get_values( 「XML = {響應}」, 「ValueParam = OutputParam」, 「Query =/Envelope/Body/timeexpresp:TimeExpenseAcknowledgmentCBM」, LAST); –

+0

在我的腦海中,您使用的是沒有命名空間的Envelope和Body,但是使用帶名稱空間的TimeExpenseAcknowledgmentC BM。你嘗試忽略命名空間嗎? – Buzzy

+0

是的..仍然不起作用。獲取相同的錯誤。 –

回答

0

這爲我工作:

char * xml_input = 
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" 
"<soapenv:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" 
"<soapenv:Body>" 
    "<timeexpresp:TimeExpenseAcknowledgmentCBM xmlns:timeexpresp=\"http://esoa.census.gov/soa/CanonicalModel/Core/CDM/TimeExpenseCDM/V1\">" 
     "<meta:RequestID xmlns:meta=\"http://esoa.census.gov/soa/CanonicalModel/Core/Common/V1\">**N53e79c17.N60c0f9d8.7.15de03dae49.N3fbe**</meta:RequestID>" 
    "</timeexpresp:TimeExpenseAcknowledgmentCBM>" 
    "</soapenv:Body>" 
"</soapenv:Envelope>"; 

Action() { 

int i, NumOfValues; 
char buf[64]; 

lr_save_string(xml_input, "XML_Input_Param"); // Save input as parameter 

lr_xml_extract("XML={XML_Input_Param}", 
     "XMLFragmentParam=Result", 
     "Query=/Envelope/Body/TimeExpenseAcknowledgmentCBM/RequestID/text()", LAST); 

lr_output_message(lr_eval_string("Extracted: {Result}")); 

return 0; 
} 

輸出:

Action.c(19): "lr_xml_extract" succeeded, 1 match processed 
Action.c(23): Extracted: **N53e79c17.N60c0f9d8.7.15de03dae49.N3fbe** 
+0

我不知道爲什麼...但是你的解決方案對我來說沒有效果:(我完全按照顯示的方式複製到一個新的腳本中......但是我找到了沒有匹配的東西 –

+0

奇怪......我不知道爲什麼它不適合你,但我仍然在12.55 – Buzzy