【发布时间】:2014-08-20 15:32:19
【问题描述】:
是否可以在一行动态属性中转换以下 groovy 请求? 该问题是针对在 SOAPui 请求中使用结果而不使用 groovy 脚本。 因为我有很多不同的日期要输入我的请求,还有我的断言。
import groovy.time.TimeCategory
use (TimeCategory) {
date = new java.text.SimpleDateFormat("yyyy-MM-dd").format(new Date() -5.month)
}
我想要一个动态属性,当然,我可以更改它。例如:
<ech:date1>${Today - 5 month}</ech:date1>
<ech:date2>${Today - 4 month}</ech:date2>
<ech:date3>${Today - 3 week}</ech:date3>
编辑:更多信息
实际上,我有一个动态属性,可以给我今天的日期,减或加 x 天,我可以在 SOAPui 中放入一个 xml 请求:
[这里,它返回我今天的日期加上二十天]
${=new java.text.SimpleDateFormat("yyyy-MM-dd").format(new Date()+20)}
示例应用程序:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ech="http://echange.service.open.bodet.com">
<soapenv:Header/>
<soapenv:Body>
<ech:importRequests01>
<ech:Requests01ToImport>
<!--Zero or more repetitions:-->
<ech:Request01>
<ech:requestDate>${=new java.text.SimpleDateFormat("yyyy-MM-dd").format(new Date() +20)}</ech:requestDate>
<!--You may enter ANY elements at this point-->
</ech:Request01>
</ech:Requests01ToImport>
</ech:importRequests01>
</soapenv:Body>
</soapenv:Envelope>
所以,我也想要同样的东西,但要问今天的日期减去/加上 x 月……等等。
【问题讨论】: