用于管理 cookie 的 SoapUI



我使用以下代码从SoapUI中的请求中获取JSESSIONID的值。

def setCookie = testRunner.testCase.testSteps["Request1"].testRequest.response.responseHeaders["Set-Cookie"]
re = /(JSESSIONID=[A-Za-z0-9]+)/
matcher = ( setCookie =~ re )
def jsesid = matcher[0][0]
log.info "$jsessid"
props = testRunner.testCase.getTestStepByName("Properties");
props.setPropertyValue('cookie',"$jsessid");

我把这个变量放在其他请求的标头中,但得到一个新的 JSESSIONID 作为响应。所以我失去了会话,因为打开了一个新的会话。

您可能已经在 SOAP UI 请求中对 rest Web 服务的请求标头发送 cookie 中遇到了类似问题的描述。

除此之外,您还需要在测试用例的选项中设置Maintain HTTP session

最新更新