简体   繁体   中英

Jmeter add Timestamp in wss

I need to put a test SOAP in Jmeter. This test is signed by Jmeter element "SOAP Message Signer". 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:

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

<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

If your question is just about making the dates variables then you can use __time and __timeShift functions this way:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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