ab post 測試 http 和 webservice 接口方法及用例

一、ab測試簡單http請求html

ab -n30000 -c1000 "http://10.1.1.21:8080/"

二、ab 測試 http 接口 (POST)web

ab -n400 -c20  -p "img.json" -T "application/x-www-form-urlencoded" "http://10.1.1.21:8080/test.do" 

img.json 爲符合接口格式的字符串json

MIME 類型 application/x-www-form-urlencoded 與 multipart/form-data 和 text/plain 參考segmentfault

相似於 curl,curl 指定 post 請 @ 指定文件app

curl "http://10.1.1.21:8080/test.do" -d  @/root/img.json

post文件裏的參數寫法以下:curl

 &param1=a&param2=b&param3=c

三、ab 測試 webservice 接口post

ab -k -T "Content-Type:text/xml;charset=UTF-8" -p data.xml -n 1000 -c 32 http://10.1.1.21:8080/services/routeService?wsdl 

注意:data.xml 必須符合 wsdl 規範,可使用 soapUI 生成測試

若是報錯:no soapaction headerurl

ab -k -T "Content-Type:text/xml;charset=UTF-8;soapaction=''" -p data.xml -n 1000 -c 32 http://10.1.1.21:8080/services/routeService?wsdl

 

來源:http://www.javashuo.com/article/p-rtrrzsze-hv.htmlspa

相關文章
相關標籤/搜索