【发布时间】:2014-03-05 21:34:36
【问题描述】:
我正在使用带有 MockService“功能”的 SoapUI 4.6.4。
此服务将收到如下请求:
code=abcdef&code=123456&code=78910
在 SoapUI(接受 Groovy 代码)的“OnRequest Script”选项卡中,我想从查询字符串参数中检索所有“代码”并循环遍历列表(对每个代码执行一些操作并更改写下回复)
到目前为止,这是我的代码:
def httpResponse = mockRequest.httpResponse
httpResponse.setContentType("application/json;charset=utf-8")
// Get all "codes" from request as a list
// loop trought list of codes one by one
def generatedResponse = "";
httpResponse.writer << "{\"codes\": [" + generatedResponse + "]}"
httpResponse.status = 200
【问题讨论】: