SoapUI 来管理 cookie

SoapUI to manage cookies

我使用下面的代码从 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");

我把这个变量放在其他请求的 headers 中,但得到一个新的 JSESSIONID 作为响应。所以我输了session,因为新开了一个

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

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