Jmeter在wss中添加时间戳

时间:2018-01-31 14:15:48

标签: testing soap jmeter wss

我需要在Jmeter中放置测试SOAP。该测试由Jmeter元素" SOAP消息签名者"签署。 我签署时间戳,正文和二进制安全令牌。 当我发送测试时,此测试发送良好但我在wssecurity标签内找不到时间戳元素,如:

<wsu:Timestamp wsu:Id="TS-C5B52CA211571174C9151739434007851">
        <wsu:Created>2018-01-31T10:25:40.078Z</wsu:Created>
        <wsu:Expires>2018-01-31T13:12:20.078Z</wsu:Expires>
    </wsu:Timestamp>

我需要用Jmeter将这个元素放在wss中。 谁知道我该怎么办? 日Thnx。

2 个答案:

答案 0 :(得分:0)

您基本上需要在请求正文中手动指定此标头,并使用__groovy() function计算当前和未来的时间戳,例如:

<wsu:Timestamp>
    <wsu:Created>
        ${__groovy(use(groovy.time.TimeCategory) { (new Date()).format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") })}
    </wsu:Created>
    <wsu:Expires>
        ${__groovy(use(groovy.time.TimeCategory) { (new Date() + 3.hours).format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") })}
    </wsu:Expires>
</wsu:Timestamp>

更多信息:Running SOAP WS-Security Load Tests in JMeter

答案 1 :(得分:0)

如果您的问题只是制作日期变量,那么您可以这样使用__time__timeShift函数:

str(data)
'data.frame':   2428 obs. of  9 variables:
 $ ID_SQ           : Factor w/ 798 levels "1","2","3","5",..: 1 1 1 1 1 2 2 
...
 $ SITUATION       : chr  "En poste" "En poste" "En poste" "En poste" ...
 $ DATE_DE         : Date, format: "1997-09-01" "1999-05-03" "2003-01-01" 
...
 $ DATE_A          : Date, format: "1999-04-26" "2002-12-31" "2006-04-28" 
...
 $ SEXE            : Factor w/ 2 levels "Féminin","Masculin": 1 1 1 1 1 1 1 
...
 $ PROMO           : Factor w/ 6 levels "1997","1998",..: 1 1 1 1 1 2 2 ...
 $ DEPARTEMENT     : Factor w/ 10 levels "BC","GCU","GE",..: 1 1 1 1 1 4 4 4 
4 4 ...
 $ NIVEAU_ADMISSION: Factor w/ 2 levels "En Premier Cycle",..: NA NA NA NA 
NA 1 1 1 1 1 ...
 $ FILIERE_SECTION : Factor w/ 4 levels "Cursus Classique",..: NA NA NA NA 
NA 4 4 4 4 4 ...


str(pdata)
'data.frame':   798 obs. of  2 variables:
 $ id   : Factor w/ 798 levels "1","2","3","5",..: 1 2 3 4 5 6 7 8 9 10 ...
 $ birth: Date, format: "1997-01-01" "1998-01-01" "1998-01-01" "2000-01-01" ...