which involves three problems
1 , Encryption to introduce a custom encryption function
2. To be able to get the first http response
3. Before the second http request, dynamically build parameters
1. Introduce encryption functions and fastjson
2. Take the last request in beanShell The response is added
in the first request, the post-processor
builds a BeanShell Post Processor
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; // get the response value String json = prev.getResponseDataAsString(); log.info("json="+json); JSONObject obj = JSON.parseObject(json); String dlapp = obj.getString("dlapp"); log.info("dlapp="+dlapp); String ret = obj.getString("ret"); log.info("ret="+ret); String capFlag = obj.getString("capFlag"); log.info("capFlag="+capFlag); // put it in a variable after parsing vars.put("dlapp",dlapp); vars.put("capFlag",capFlag); vars.put("ret",ret);
3. Before the second http request, the parameters must be dynamically constructed. For
the second http request, the parameter value of the request uses the jmeter variable
such as
sign=${sign}
Add, preprocessor
Build a BeanShell PreProcessor
to call the encryption function to encrypt and put it into a variable
String capFlag = vars.get("capFlag"); String dlapp= vars.get("dlapp"); String ret= vars.get("ret"); log.info("dlapp="+dlapp); log.info("capFlag="+capFlag); log.info("ret="+ret); vars.put("dlapp",dlapp); vars.put("capFlag",capFlag); vars.put("ret",ret);
View jmeter log log