2013-10-08 92 views
0

我已經喜歡參數拋出錯誤

user logs in (/login) 

navigate to the reservations page to get all the reservation id (/reservations) 

    Through regular expression I retrieve all reservation ids like reservationids_1=19678406 etc... 

    navigate to the first reservation id (/reservation/${reservationids_1}) 

在每次導航頁面的情景,HTTP頭經理需要適用於網頁,其中基本handShakeKey url,secretKey,publicKey的組合。 (secretKey,publicKey都是靜態的,但url變化)

對於像(/ login,/ reservations)這樣的靜態URL,我在開頭添加了一個BSF預處理器並聲明變量並在HTTP頭管理器中使用這些變量作爲$ {handshakeKey_reservations},$ {handshakeKey_login}等工作非常好。

var urls = ["login", "reservations", "logout", "profile"]; 

    for (var i = 0; i < urls.length; i++) { 

    var handShakeKeyForStaticUrls = CryptoJS.SHA1("/"+urls[i]+"abcdediiebneC"+"12345678"); 

     handShakeKeyForStaticUrls = handShakeKeyForStaticUrls.toString(CryptoJS.enc.Base64); 

    vars.put("handshakeKey_"+urls[i], handShakeKeyForStaticUrls); 

     } 

現在的問題是動態URL(/預訂/ $ {}預留ID,/預訂/ $ {}預留ID /總結等.......)

作爲一個工作,我身邊試圖把一個BSF後處理器每個動態網址HTTTP採樣

//reservationid = "19678406"; 

reservationid = "${reservationids_1}"; 

vars.put ("val", reservationid); 

vars.put ("type", typeof(reservationid)); 

var handShakeKeyForDynamicUrls = CryptoJS.SHA1("/reservation/" + reservationid +"abcdeeee"+"12345678"); 

handShakeKeyForDynamicUrls = handShakeKeyForDynamicUrls.toString(CryptoJS.enc.Base64); 

vars.put("handShakeKeyForDynamicUrls", handShakeKeyForDynamicUrls); 

在我使用handshakeKey $ {} handShakeKeyForDynamicUrls HTTP報頭管理器之前

當我使用預留ID =「19 678406「在BSF採樣器中硬編碼(javascript);

其做工精細爲例

GET https://<servername>/reservation/19678406 
handshake key :- 21d1ce663d079b5583d76730f6f1477d8f6ae 
Also in the debug sampler type and val coming as string and 19678406 which is OK 

然而,當我使用預留ID = 「$ {} reservationids_1」 在BSF採樣(JavaScript的);它失敗

GET https://<servername>/reservation/19678406 
    handshake key :- b607876d69f5d59c5258bcd5a2a064bbcf35 
Also in the debug sampler type and val coming as string and 19678406 

所以不明白兩者是如何不同。爲什麼它失敗了。如果我傳遞一個參數(兩種情況下的字符串類型和值都相同),爲什麼它會失敗,而不是硬編碼值。

對此有何看法?

注意: - 日誌查看器中沒有錯誤。

回答

0

我做了一個解決方法,它工作正常。

之前增加了另一個BSF採樣器(BeanShell的),並像

vars.put ("reservationid", "${reservationid_1}"); 

那麼接下來BSF後處理器(Java腳本)提到

var handShakeKeyForDynamicUrls = CryptoJS.SHA1("/reservation/${reservationid}" +"abcdeeee"+"12345678"); 

handShakeKeyForDynamicUrls = handShakeKeyForDynamicUrls.toString(CryptoJS.enc.Base64); 

vars.put("handShakeKeyForDynamicUrls", handShakeKeyForDynamicUrls);