简体   繁体   English

Jmeter在WSS中添加时间戳

[英]Jmeter add Timestamp in wss

I need to put a test SOAP in Jmeter. 我需要在Jmeter中放入测试SOAP。 This test is signed by Jmeter element "SOAP Message Signer". 该测试由Jmeter元素“ SOAP消息签名者”签名。 I sign Timestamp, body and binary security token. 我签署时间戳记,正文和二进制安全令牌。 When i send test, this test send well but I'm not found timestamp element inside wssecurity tags like: 当我发送测试时,该测试发送良好,但在wssecurity标记内找不到timestamp元素,例如:

<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>

I need to put this element inside wss with Jmeter . 我需要将该元素放入Jmeter的wss中。 Anyone knows how can i do it? 有人知道我该怎么做吗? Thnx. 谢谢

You basically need to manually specify this header in the request body and use __groovy() function to calculate current and future timestamps like: 您基本上需要在请求正文中手动指定此标头,并使用__groovy()函数来计算当前和将来的时间戳,例如:

<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>

More information: Running SOAP WS-Security Load Tests in JMeter 详细信息: 在JMeter中运行SOAP WS-Security负载测试

If your question is just about making the dates variables then you can use __time and __timeShift functions this way: 如果您的问题只是关于设置日期变量,则可以通过以下方式使用__time__timeShift函数:

 <wsu:Timestamp wsu:Id="TS-C5B52CA211571174C9151739434007851">
    <wsu:Created>${__time(yyyy-MM-dd'T'HH:mm:ss.SSS'Z',)}</wsu:Created>
    <wsu:Expires>${__timeShift(yyyy-MM-dd'T'HH:mm:ss.SSS'Z',,PT3H,,)}</wsu:Expires>
</wsu:Timestamp>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM