ab post 测试 http 和 webservice 接口方法及用例

来源:互联网 发布:建信养老飞月宝 知乎 编辑:程序博客网 时间:2024/03/29 17:36

原文

AB(ApacheBench) 是 Apache 自带的超文本传输协议 (HTTP) 性能测试工具。 其设计意图是描绘当前所安装的 Apache 的执行性能, 主要是显示 Apache 每秒可以处理多少个请求。

使用 ab -help 查看帮助界面

  1. ab测试简单http请求

    ab -n30000 -c1000 "http://10.1.1.21:8080/"
  2. ab 测试 http 接口 (POST)

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

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

    MIME 类型 application/x-www-form-urlencoded 与 multipart/form-data 和 text/plain 参考

    类似于 curl,curl 指定 post 请 @ 指定文件

    curl "http://10.1.1.21:8080/test.do" -d  @/root/img.json
  3. ab 测试 webservice 接口

    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 header

    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
0 0
原创粉丝点击