Loadrunder脚本篇——webservice接口测试(一)

函数介绍

soap_request

函数执行一个SOAP请求

函数原型

int soap_request( const char *StepName, ExpectedResponse, URL, , [Attachments,] LAST);

 

参数说明:

StepName: 函数名称

 

ExpectedResponse:可接受的响应类型

1)ExpectedResponse=SoapResult: 接受SOAP输出响应,且出现SOAP错误响应则标记失败(Accept SOAP output responses and fail on SOAP faults)

2)ExpectedResponse=SoapFault: 接受SOPA错误响应,且SOAP正常输出响应则标记失败(Accept SOAP faults and fail on SOAP output responses)

3)ExpectedResponse=AnySoap: 接受SOAP输出和SOAP错误响应(Accept both SOAP output and SOAP fault responses.)

 

URL: WebService需要加载的url地址

 

XMLEnvelope

用于必备元素列表,使用以下字符串格式:

"Element=value"

SOAPEnvelope: 发送给服务器是XML数据包

Snapshot: 包含函数快照的.inf文件名

ResponseParam:  存储服务器响应的输出参数。

 

Attachments: 需要发送、接收的附件(可选参数) 详情查阅官方文档 Attachment Specifications

 

LAST: 表名Specifications  list结束的标记

 

Web Service接口测试

协议选择

Loadrunner <wbr>脚本开发-soap_request函数介绍及WebService接口测试

 

脚本

Loadrunner <wbr>脚本开发-soap_request函数介绍及WebService接口测试

 

Action()
{

soap_request("StepName=soap_request",

 

"ExpectedResponse=SoapResult",

 

"SOAPEnvelope="

 

"<soapenv:Envelope xmlns:\"http://schemas.xmlsoap.xml.org/soap/envelope/"

 

"\"xmlns:web=\"http://WebXml.com.cn/\">"

 

"<soapenv:Header/>"

 

"<soapenv:Body>"

 

"<web:getSupportProvince/>"

 

"</soapenv:Body>"

 

"</soapenv:Envelope>",

 

"URL=http://webxml.com.cn/WebServices/WeatherWebService.asmx?",

 

"Snapshot=soap_request.inf",

 

"ResponseParam=response",

 

LAST);

 

return 0;
}

 

 

 

 

运行结果:

Loadrunner <wbr>脚本开发-soap_request函数介绍及WebService接口测试

 

对比SoapUI测试结果

Loadrunner <wbr>脚本开发-soap_request函数介绍及WebService接口测试

posted @ 2018-01-31 14:17  残~枫~  阅读(294)  评论(0编辑  收藏  举报