You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在SoapUI中能否使用会话变量解决异步Mock服务多请求冲突问题?

Solution for Request ID Overwriting in SoapUI Mock Service Load Tests

Absolutely, SoapUI provides session-scoped storage to keep request-specific values isolated from one another—perfect for solving your load test issue where the global context was getting overwritten by concurrent requests. Here's how to fix it:

1. Store Request ID in the Request Session (Instead of Global context)

In your Script section, replace the context.put call with code that uses the request's dedicated, isolated session:

// Store request ID in the request-specific session
mockRequest.getSession().put("requestid", mockRequest.requestid)

2. Retrieve Request ID from the Same Session in AfterScript

In your AfterScript section, fetch the ID from the session instead of the shared global context:

// Get the request ID from the same session it was stored in
def requestId = mockRequest.getSession().get("requestid")
// Use requestId in your callback logic here

Why This Works

  • The global context object is shared across all requests handled by the Mock Service. Concurrent requests will overwrite its values instantly, which is exactly what caused your callback ID mismatch in load tests.
  • Each mockRequest has its own unique Session object (when session support is enabled). This session is tied directly to the individual request, so values stored here won't interfere with other requests.

Quick Setup Check: Enable Session Support

Make sure your Mock Service has sessions enabled to activate this isolated storage:

  • Open your Mock Service's settings
  • Navigate to the Session section
  • Check the box for Enable Sessions (this ensures each incoming request gets its own dedicated session space)

With this setup, each request's ID will stay isolated, so your callbacks will always use the correct ID even during high-concurrency load tests.

内容的提问来源于stack exchange,提问作者mnhmilu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 04:19:30