以天气预报网站为例:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl

一、web_service_call模式

步骤如下:

经过增加事务和if 判断的脚本如下:

Action()
{ lr_start_transaction("获取天气预报"); web_service_call(
"StepName=getWeatherbyCityName_102",
"SOAPMethod=WeatherWebService|WeatherWebServiceSoap|getWeatherbyCityName", //服务名称|soap|获取哪个接口(城市天气预报)
"ResponseParam=response", //返回的参数信息
"Service=WeatherWebService", // webservice的服务
"ExpectedResponse=SoapResult", //请求的返回
"Snapshot=t1555506477.inf",
BEGIN_ARGUMENTS, //输入参数开始
"theCityName={NewParam}", //请求输入
END_ARGUMENTS, //结束参数
BEGIN_RESULT, //返回值得开始
"getWeatherbyCityNameResult/*[2]=Param_string", //返回的参数保存在Param_string
END_RESULT, //返回值结束
LAST); if(strcmp(lr_eval_string("{NewParam}"),lr_eval_string("{Param_string}"))==){
lr_end_transaction("获取天气预报", LR_PASS);
}else{
lr_end_transaction("获取天气预报", LR_FAIL);
} return ; }

二、soap_request模式 (外加查看请求报文的小插曲)

当开发只给你一个地址时,我们可以使用 soap UI 工具查看 步骤如下:

lr12 操作步骤如下:

根据城市名获取天气预报的接口文档地址:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?op=getSupportCity

脚本加上改造之后的如下:

Action()
{
lr_convert_string_encoding(lr_eval_string("{city_name}"),NULL,"utf-8","city");
lr_save_string(lr_eval_string("{city}"),"cityName");
// lr_think_time(10);
lr_start_transaction("获取天气预报"); soap_request("StepName=SOAP Request",
"URL=http://www.webxml.com.cn/WebServices/WeatherWebService.asmx",
"SOAPEnvelope="
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
"<soap:Body>"
"<getWeatherbyCityName xmlns=\"http://WebXml.com.cn/\">"
"<theCityName>{cityName}</theCityName>"
"</getWeatherbyCityName>"
"</soap:Body>"
"</soap:Envelope>",
"SOAPAction=http://WebXml.com.cn/getWeatherbyCityName",
"ResponseParam=response",
"Snapshot=t1555573201.inf",
LAST); lr_xml_get_values("XML={response}",
"Query=/Envelope/Body/getWeatherbyCityNameResponse/getWeatherbyCityNameResult/string[2]",
"ValueParam=responseValue",
LAST);
lr_output_message("返回城市名称:%s",lr_eval_string("{responseValue}"));
if(strcmp(lr_eval_string("{responseValue}"),lr_eval_string("{city_name}"))==){ //响应的参数 与参数化转码之前的参数对比
lr_end_transaction("获取天气预报", LR_PASS);
}else{
lr_end_transaction("获取天气预报", LR_FAIL);
} return ;
}

运行结果:

三、web_custom_request函数,创建HTTP协议完成webserive协议

脚本如下:

Action()
{
web_custom_request("web_custom_request",
"URL=http://www.webxml.com.cn/WebServices/WeatherWebService.asmx",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"Mode=HTTP",
"EncType=application/soap+xml; charset=utf-8",
"Body=<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">"
"<soap12:Body>"
"<getWeatherbyCityName xmlns=\"http://WebXml.com.cn/\">"
"<theCityName>59134</theCityName>"
"</getWeatherbyCityName>"
"</soap12:Body>"
"</soap12:Envelope>",
LAST); return ;
}

loadrunner之WebServices协议脚本编写(三种请求模式)的更多相关文章

  1. Loadrunner Webservice接口性能测试脚本编写优化总结

    本文主要介绍使用Loadrunner Webservice接口性能测试脚本编写及优化总结. 1.Webservice协议脚本编写流程 下面介绍使用Loadrunner 11调用Webservice接口 ...

  2. LoadRunner录制HTTPS协议脚本

    学习LoadRunner录制HTTPS协议脚本,其实是一个意外的收获.当我拿到要测试的URL时,我像以前的步骤一样录制脚本,但是录制结束后,发现并没有生成脚本,开始以为是LoadRunner的原因,我 ...

  3. js架构设计模式——你对MVC、MVP、MVVM 三种组合模式分别有什么样的理解?

    你对MVC.MVP.MVVM 三种组合模式分别有什么样的理解? MVC(Model-View-Controller)MVP(Model-View-Presenter)MVVM(Model-View-V ...

  4. 云计算的三种服务模式:SaaS/PaaS/IaaS

    转载http://blog.chinaunix.net/uid-22414998-id-3141499.html 定义 云计算主要分为三种服务模式,而且这个三层的分法重要是从用户体验的角度出发的: S ...

  5. 云计算三种服务模式SaaS、PaaS和IaaS及其之间关系(顺带CaaS、MaaS)

    云计算架构图 很明显,这五者之间主要的区别在于第一个单词,而aaS都是as-a-service(即服务)的意思,这五个模式都是近年来兴起的,且这五者都是云计算的落地产品,所以我们先来了解一下云计算是什 ...

  6. 云计算 --> 三种服务模式IaaS,PaaS,SaaS

    三种服务模式IaaS,PaaS,SaaS “云”其实是互联网的一个隐喻,“云计算”其实就是使用互联网来接入存储或者运行在远程服务器端的应用,数据,或者服务.任何一个使用基于互联网的方法来计算,存储和开 ...

  7. APP的三种开发模式

    转载于http://pleasureswx123.github.io/2014/09/15/APP%E7%9A%84%E4%B8%89%E7%A7%8D%E5%BC%80%E5%8F%91%E6%A8 ...

  8. 云计算的三种服务模式:IaaS,PaaS和SaaS

    云服务”现在已经快成了一个家喻户晓的词了.如果你不知道PaaS, IaaS 和SaaS的区别,那么也没啥,因为很多人确实不知道. “云”其实是互联网的一个隐喻,“云计算”其实就是使用互联网来接入存储或 ...

  9. 初识云计算的三种服务模式 (IaaS SaaS PaaS)

    近期公司在使用其它云服务的同一时候.要封装自己的云服务,以下作为开发产品前的热身.来了解云计算中的三种服务模式,笔者也是从网络上查找,进行综合总结.请拍.. 三种服务模式 依据如今最经常使用.也就是比 ...

随机推荐

  1. 访谈:BugPhobia’s Brief Communication

    0x01 :采访的学长简介 If you weeped for the missing sunset, you would miss all the shining stars 梁野,北京航空航天大学 ...

  2. Linux实践二:模块

    一.基本模块的实现: 1.进程遍历打印输出 2.简单地编写一个新的系统调用(替换空的系统调用号) 基本模块学到的知识点: 1.相关指令 make oldconfig 配置内核 make 编译内核 ma ...

  3. Android中Json数据读取与创建的方法

    转自:http://www.jb51.net/article/70875.htm 首先介绍下JSON的定义,JSON是JavaScript Object Notation的缩写. 一种轻量级的数据交换 ...

  4. myeclipse从SVN检出项目报错

    今天是在公司实习的第一天,从SVN服务器检出项目后发现报错. 解决方法: 1. 右键项目,选择属性properties-->选择resource-->将others选中并换为UTF-8 2 ...

  5. PHP开发:Eclipse版环境配置

    软件: 1.eclipse php版本下载地址:http://www.eclipse.org/downloads/packages/eclipse-php-developers/heliosr 2.A ...

  6. 配置Activiti Explorer使用MYSQL

    http://blog.csdn.net/lxxxzzl/article/details/39583977

  7. 数据驱动测试之—— Excel+TestNG

    对于利用Webdriver做自动化的童鞋,对于如何将元素或者输入数据如何和编码分离都应该不会太陌生,本着一边学习一边分享的心态,大概总结了一下关于利用CSV.XML以及Excel来存放数据,然后在结合 ...

  8. HTML页面打印

    <style media=print>.Noprint{display:none;}</style> <object id="WebBrowser" ...

  9. Delphi编程中动态菜单要点归纳

      一.创建菜单并添加项目 在设计程序时,有时需要动态创建菜单, 通常使用以下的语句: PopupMenu1 := TPopupMenu.Create(Self);  Item := TMenuIte ...

  10. 关于C# 怎么调用webapi来获取到json数据

      /// <summary>        /// 调用api返回json        /// </summary>        /// <param name=& ...