您的位置:首页 > 产品设计 > UI/UE

SoapUI脚本保存变量,加一BUG

2015-09-30 15:05 537 查看
.....看看,好高深....


保存为全局变量,可以在groovy脚本中,也可以在断言脚本中

String _url=System.getProperties().getProperty("_url");
_url+="sss"+";"; // 每次重定向就保存一次
System.getProperties().setProperty("_url",_url);//先设置一个键位DBType的属性


主要是好记

BUG,

soapUI自带重定向http,其实是soapUI手动重定向的,不是httpclient自动的

有的服务器会要 header中的HOST值,如 192.168.1.2:8080,那么host也应该一致,返回的Location指令会到8080

看看改以后代码:

package com.eviware.soapui.impl.wsdl.submit.transports.http;

HttpClientRequestTransport


String location = httpResponse.getFirstHeader("Location").getValue();
URI uri = new URI(new URI(httpMethod.getURI().toString(), true), location, true);
java.net.URI newUri = HttpUtils.createUri(uri.getScheme(), uri.getEscapedUserinfo(), uri.getHost(), uri.getPort(), uri.getEscapedPath(), uri.getEscapedQuery(), uri.getEscapedFragment());
((ExtendedHttpMethod)getMethod).setURI(newUri);
((ExtendedHttpMethod)getMethod).setHeader("Host", uri.getHost()+":"+uri.getPort());//添加端口!!
//  不加端口号是为何,真是受不了,ai,真心麻烦
String _url=System.getProperties().getProperty("_url");
_url+=uri+";"; // 每次重定向就保存一次
System.getProperties().setProperty("_url",_url);//先设置一个键位DBType的属性
//System.getProperties().getProperty("_url");//后通过getProperty方法得到DBType的值。
//我添加了新内容

由于是测试工具,有时需要拦截中间的url,所以做了一个保存!

修改以后替换回去就好了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: