{"id":153210,"date":"2019-08-20T09:10:04","date_gmt":"2019-08-20T01:10:04","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=153210"},"modified":"2019-08-08T16:11:19","modified_gmt":"2019-08-08T08:11:19","slug":"jmeter","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/jmeter.html","title":{"rendered":"\u5229\u7528Java\u5904\u7406Jmeter\u63a5\u53e3\u5e38\u7528\u53c2\u6570"},"content":{"rendered":"
\u4e00\u3001\u7b7e\u540d\u53c2\u6570sign\u7b97\u6cd5\u7531\u6587\u5b57\u63cf\u8ff0\uff0c\u7b97\u6cd5\u9700\u81ea\u5df1\u7f16\u5199<\/p>\n
\u4e8c\u3001 \u53c2\u6570param_json\u4e3a\u53d8\u5316\u7684json\u4e32(json\u4e32\u5185\u8ba2\u5355\u53f7\u552f\u4e00)<\/p>\n
1. \u624b\u52a8\u62fc\u63a5\u540e\u5728https:\/\/www.cmd5.com\/\u52a0\u5bc6\uff0c\u8f83\u4e3a\u9ebb\u70e6\uff0c\u4e14\u5bb9\u6613\u51fa\u9519<\/p>\n
2. \u7f16\u5199python\u6216java\u811a\u672c\uff0c\u5b9e\u73b0\u52a0\u5bc6\uff0c\u6bd4\u65b9\u6cd51\u9ad8\u6548<\/p>\n
3. \u5728postman\u7684Pre-request Script<\/p>\n
\r\n let app_secret = \"xxx\"; \/\/\u7b7e\u540dapp_secret\r\n let access_token = \"xxx\";\r\n let app_key = 'xxx';\r\n let method = 'xxx';\r\n let param_json ='{\"thirdOrder\":\"xxx\" ...}'; \/\/\u53c2\u6570\u7701\u7565\r\n let timestamp ='2018-06-06 13:52:03'; \/\/ \u6ce8\u610f\u683c\u5f0f\r\n let v = '1.0';\r\n \r\n \/\/\u62fc\u63a5\r\n sign = app_secret +\"access_token\"+ access_token +\"app_key\"+app_key+\"method\"+method+\"param_json\"+param_json+\"timestamp\"+timestamp+\"v\"+v+app_secret;\r\n console.log(sign);\r\n sign = CryptoJS.MD5(sign).toString();\r\n console.log(sign);\r\n \r\n \/\/\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\r\n postman.setEnvironmentVariable(\"sign\", sign);\r\n<\/pre>\n\u6548\u7387\u5927\u5927\u63d0\u9ad8\uff0c\u63a8\u8350\u65b9\u6cd5\u3002<\/p>\n
Jmeter\u5904\u7406\u65b9\u6cd5<\/strong><\/span><\/div>\n-------4.1 \u7f16\u5199java\u4ee3\u7801\u5b9e\u73b0\u52a0\u5bc6\u4ee5\u53ca\u751f\u6210\u552f\u4e00\u8ba2\u5355\u53f7<\/p>\n
-------4.2 \u5c06java\u4ee3\u7801\u6253\u5305\u540e\uff0c\u62f7\u8d1d\u5230jmeter\u7684lib\/ext\u76ee\u5f55\u4e0b<\/p>\n
-------4.3 \u5728\u6d4b\u8bd5\u8ba1\u5212\u4e2d\u5f15\u5165jar<\/p>\n
-------4.4 \u6dfb\u52a0BeanShell Sampler\uff0c\u7f16\u5199\u811a\u672c(\u7c7b\u4f3cjava\u8bed\u6cd5)<\/p>\n
\r\n \/\/ \u5bfc\u5165\u5916\u90e8jar\u5305(\u8ba1\u7b97sign)\r\n import com.wdzy.tools.GetSign;\r\n \r\n \/\/ \u57fa\u672c\u4e0d\u53d8\u53c2\u6570\r\n String app_secret = \"xxx\"; \/\/\u7b7e\u540dapp_secret\r\n String access_token = \"xxx\";\r\n String app_key = \"xxx\";\r\n String method = \"xxx\";\r\n String timestamp =\"2018-06-06 13:52:03\";\r\n String v = \"1.0\";\r\n \r\n \/\/ \u5904\u7406\u7b2c\u4e09\u65b9\u8ba2\u5355\u53f7\r\n String param_json = new GetSign().getParamJson();\r\n String param_json = param_json.toString();\r\n vars.put(\"param_json\",param_json.toString());\r\n \r\n \/\/ \u62fc\u63a5sign\u4e32\r\n sign = app_secret +\"access_token\"+ access_token +\"app_key\"+app_key+\"method\"+method+\"param_json\"+param_json+\"timestamp\"+timestamp+\"v\"+v+app_secret;\r\n \/\/ \u8ba1\u7b97MD5\u503c\r\n String result = new GetSign().MD5(sign);\r\n \r\n System.out.println(result);\r\n \/\/ \u5c06sign\u7ed3\u679c\u5b58\u50a8\u5230\u4f5c\u7528\u57df\r\n vars.put(\"sign\",result.toString());\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"\u4e00\u3001\u7b7e\u540d\u53c2\u6570sign\u7b97\u6cd5\u7531\u6587\u5b57\u63cf\u8ff0\uff0c\u7b97\u6cd5\u9700\u81ea\u5df1\u7f16\u5199 \u4e8c\u3001 \u53c2\u6570param_json\u4e3a\u53d8\u5316\u7684json\u4e32(json […]<\/p>\n","protected":false},"author":1479,"featured_media":153211,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-153210","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/153210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1479"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=153210"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/153210\/revisions"}],"predecessor-version":[{"id":153241,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/153210\/revisions\/153241"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/153211"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=153210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=153210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=153210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}