当我调用使用“Set-Cookie”标头发送响应的Web服务时,soapui会为后续调用缓存cookie。如何在后续通话中清除这些cookie?
或者有没有办法从响应中的端点“不接受”cookie?
我正在使用免费的Soap UI 4.5.0
答案 0 :(得分:1)
查看这篇关于eviware的帖子forum其中一个回复显示如何清除cookie
答案 1 :(得分:1)
我从Abhishek的另一个答案开始阅读link,并在此link找到了答案:
对于正在寻找答案的人来说,这就是我现在正在使用的内容:
基本上,您必须使用要运行的请求创建一个测试用例,并且您将在TestSteps中获得一个脚本编辑器,您可以在其中使用以下groovy脚本。
import com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport
def myCookieStore = HttpClientSupport.getHttpClient().getCookieStore()
def myCookies = myCookieStore.getCookies()
// find the session cookie
def sessionCookie
myCookies.each {
// print all of them
log.info(it.name + " = " + it.value)
if (it.name == "JSESSIONID"){
sessionCookie = it
}
}
// if you want to update the cookie value
// sessionCookie.value = "new cookie value here..."
// deleting all cookies
myCookieStore.clear()
// to delete only specific
//if (sessionCookie != null) {
// sessionCookie.expiryDate = new Date()-1 // yesterday
// myCookieStore.clearExpired(new Date()-1)
//}
// check if the cookies are really removed
myCookies = myCookieStore.getCookies()
log.info("After Removing Session Cookie");
myCookies.each {
// print all of them
log.info(it.name + " = " + it.value)
}
// if you want to create your own cookie
//import org.apache.http.impl.Cookie.BasicClientCookie
//def myNewCookie = new BasicClientCookie("cookie_name", "cookie_value")
//myNewCookie.version = 1
//myNewCookie.domain = "qa.test"
//myCookieStore.addCookie(myNewCookie)
// or from another cookie
//def myNewCookie = new BasicClientCookie("cookie_name", interestingCookie.value)