2013-10-08 82 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);