首页 > 解决方案 > SoapUI 来管理 cookie

问题描述

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

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 作为响应。所以我失去了会话,因为打开了一个新会话。

标签: httpsoapuisession-cookiesjsessionid

解决方案


您可能已经在Sending cookie as request header in SOAP UI request for rest web service 中遇到过类似问题的描述。

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


推荐阅读