性能测试基础-HTTP用例设计

本文介绍了几种常见的HTTP请求方式,包括JSON格式请求、WEBSERVICE格式请求及表单提交方式等。详细展示了不同请求类型的构造方法及其应用实例,有助于理解如何在实际开发中使用这些请求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

JSON格式请求: 

web_custom_request("https://xx.xx.xx.xx:xx/pvcpappinf//msgcustomization/xinPowGenDay, //接口地址
"URL=https://xx.xx.xx.xx:xx/pvcpappinf/msgcustomization/xinPowGenDay", 
"Method=POST",  
        "Referer=", 
        "Mode=HTTP",
        "EncType=application/json; charset=UTF-8",
        "Body={\"userNo\":\"csadmin\"}",//JSON报文
LAST);

WEBSERVICE格式请求(REQUEST方式模拟):

web_custom_request("GetProductInfo",
        "URL=http://xx.xx.xx.xx:xx/orderproductservice.svc",
        "Method=POST", 
        "Referer=",
        "Mode=HTTP",
        "EncType=application/soap+xml; charset=UTF-8",
        "Body=<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><a:Action s:mustUnderstand=\"1\">http://tempuri.org/IProductService/GetProductInfo</a:Action><a:MessageID>urn:uuid:27696e1a-29cd-4c49-aa94-e9d9784ee711</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand=\"1\">http://xx.xx.xx.xx:xx/orderproductservice.svc</a:To></s:Header><s:Body><GetProductInfo xmlns=\"http://tempuri.org/\"><productId>{producid}</productId></GetProductInfo></s:Body></s:Envelope>",
LAST);

表单提交方式:

web_submit_data("default.aspx",

    "Action=http://lazarus/flightnet/default.aspx",

    "Method=POST",

    "TargetFrame=",

    "RecContentType=text/html",

    "Referer=http://lazarus/flightnet/",

    "Snapshot=t7.inf",

    "Mode=HTML",

    ITEMDATA,

    "Name=grpType", "Value=radRoundtrip", ENDITEM,

    "Name=lstDepartingCity", "Value=DEN", ENDITEM,

    "Name=lstDestinationCity", "Value=LAX", ENDITEM,

    "Name=txtDepartureDate", "Value=8/19/2003", ENDITEM,

    "Name=txtReturnDate", "Value=8/19/2003", ENDITEM,

    "Name=txtQuantity", "Value=1", ENDITEM,

    "Name=radClass", "Value=1", ENDITEM,

    "Name=radSeat", "Value=1", ENDITEM,

    "Name=btnAvailableFlights", "Value=Next >", ENDITEM,

    LAST );

带表头的HTTTP请求:(模拟APP端请求,会增加特殊的头验证)

web_add_header("user-agent","android");
web_add_header("Connection","false");
web_add_header("Authorization","");
web_add_header("Accept-Encoding","Accept_Encoding");
web_add_header("Content-Type","application/json;charset=UTF-8");
 
lr_start_transaction("articleAdvertList");
 web_reg_find("Text/IC=code\":\"000000", "SaveCount=abc_count", "LAST"); 
    web_custom_request("articleAdvertList", 
        "Method=POST", 
        "Resource=0",
        "Referer= http://192.168.62.151:8130", 
        "Snapshot=t2.inf", 
        "Mode=HTTP", 
        //"EncType=",
        "Body={sender1}",
         LAST);

转载于:https://www.cnblogs.com/stone-xiao/p/6001199.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值