|
LoadRunner中Web Services的HTTP请求脚本开发(以解决LR的Web Services协议100用户的限制)
网上流传的LR8.0的license只有global 100和web10000两种。用Web Services录制或用soap_request自开发的测试脚本,都走的是LR的Web Services协议,场景执行时都要受到100用户的限制。下面谈谈如何解决这个受限问题:
如前所讲SOAP请求是一个HTTP POST请求,一个特殊的HTTP请求,所以我们完全可以用HTTP协议来开发Web Services测试脚本,以避免license的受限问题。
脚本如下:
#include "web_api.h"
Action()
{
web_add_header("Content-Type", "text/xml; charset=utf-8");
web_add_header("Accept", "application/soap+xml, application/dime,multipart/related, text/*");
web_add_header("Cache-Control", "no-cache");
web_add_header("Pragma", "no-cache");
web_add_header("SOAPAction", "sim.SyncOrderRelation");
lr_start_transaction("httpSoap");
web_reg_find("Text=<soapenv:Fault>", "Fail=Found", LAST);
web_reg_find("Text=ErrorList", "Fail=Found", LAST);
web_custom_request("SoapHTTPRequest",
"URL=http://test1//wapprovision/provision.asmx",
"Method=POST",
"Resource=0",
"RecContentType=text/xml",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
"EncType=text/xml; charset=utf-8",
"Body=<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap:Envelope xmlns:soap="
"\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsi="
"\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns:xsd="
"\"http://www.w3.org/2001/XMLSchema\">"
"\n<soap:Header>"
"\n<TransactionID xmlns=\"http://www.monternet.com/dsmp/schemas/\">110000000001</TransactionID>"
"\n</soap:Header>"
"\n<soap:Body>"
"\n<SyncOrderRelationReq xmlns=\"http://www.monternet.com/dsmp/schemas/\">"
"\n<MsgType>SyncOrderRelationReq</MsgType>"
"\n<Version>1.5.0</Version>"
"\n<Send_Address>"
"\n<DeviceType>201</DeviceType>"
"\n<DeviceID>SZ12345</DeviceID>"
"\n</Send_Address>"
"\n<Dest_Address>"
"\n<DeviceType>11</DeviceType>"
"\n<DeviceID>BJ88888</DeviceID>"
"\n</Dest_Address>"
"\n<FeeUser_ID>"
"\n<UserIDType>1</UserIDType>"
"\n<MSISDN>13651412464</MSISDN>"
"\n<PseudoCode>011</PseudoCode>"
"\n</FeeUser_ID>"
"\n<DestUser_ID>"
"\n<UserIDType>2</UserIDType>"
"\n<MSISDN>{DMSISDN}</MSISDN>"
"\n<PseudoCode>{PCode}</PseudoCode>"
"\n</DestUser_ID>"
"\n<LinkID>ForLulu</LinkID>"
"\n<ActionID>{ActionId}</ActionID>"
"\n<ActionReasonID>7</ActionReasonID>"
"\n<SPID>900513</SPID>"
"\n<SPServiceID>{SPId}</SPServiceID>"
"\n<AccessMode>{AccessMode}</AccessMode>"
// "\n<FeatureStr>news</FeatureStr>"
"\n</SyncOrderRelationReq>"
"\n</soap:Body>"
"\n</soap:Envelope>",
LAST);
lr_end_transaction("httpSoap", LR_AUTO);
return 0;
} |
|