1、新增脚本,选择协议
2、导入wsdl路径
1)导入步骤
2)导入后查看接口
3、选择接口,写脚本
1)选择接口,填写参数,保存响应结果(可不保存)
2)生成脚本
Action()
{
web_service_call( "StepName=getSupportCity_101",
"SOAPMethod=WeatherWebService|WeatherWebServiceSoap|getSupportCity",
"ResponseParam=response",
"Service=WeatherWebService",
"ExpectedResponse=SoapResult",
"Snapshot=t1556617084.inf",
BEGIN_ARGUMENTS,
"byProvinceName=湖北",
END_ARGUMENTS,
BEGIN_RESULT,
"getSupportCityResult=SupportCity-HB",
END_RESULT,
LAST);
return 0;
}
4、添加检查点
执行后,进入Tree视图,选择要检查的值对应的string,右键选择“Insert XML Check”
5、关联
1)步骤
执行后,进入Tree视图,选择要关联的值对应的string,右键选择“Save value in parammeter”,如下图所示。
2)Save value in param 与Save XML in param差异
6、参数化
与http脚本参数化操作一致
7、脚本参考
检查点、关联(两种)加上后的脚本如下
Action()
{
web_service_call( "StepName=getSupportCity_101",
"SOAPMethod=WeatherWebService|WeatherWebServiceSoap|getSupportCity",
"ResponseParam=response",
"Service=WeatherWebService",
"ExpectedResponse=SoapResult",
"Snapshot=t1556617084.inf",
BEGIN_ARGUMENTS,
"byProvinceName=湖北",
END_ARGUMENTS,
BEGIN_RESULT,
"getSupportCityResult=SupportCity-HB",
END_RESULT,
LAST);
lr_xml_extract("XML={response}",
"FastQuery=/Envelope/Body/getSupportCityResponse/getSupportCityResult/string",
"XMLFragmentParam=GetCity_XML",
LAST);
lr_xml_get_values("XML={response}",
"FastQuery=/Envelope/Body/getSupportCityResponse/getSupportCityResult/string",
"ValueParam=GetCity_Value",
LAST);
lr_xml_find("XML={response}",
"FastQuery=/Envelope/Body/getSupportCityResponse/getSupportCityResult/string",
"Value=武汉 (57494)",
LAST);
return 0;
}