WebService发布后其服务是封装在一个wsdl文件中。客户端发请求主要是向发布好的wsdl地址以SOAP 方式发请求。
SOAP协议请求也是基于http协议传输。利用这一点我们可以用http协议中自定义请求方法web_custom_request()来编写脚本发送请求到WebService。
下面附件是脚本示例:
web_add_header("Content-Type", "text/xml; charset=utf-8");
web_add_header("Accept", "*.*");
web_add_header("Cache-Control", "no-cache");
web_add_header("SOAPAction", "");
//插入添加主菜单事务扩展接口
// lr_rendezvous("addMenuInfo");
lr_start_transaction("addMenuInfo");
web_custom_request("HttpSoapRequest",
"URL=http://xxxxxxxxxxx/autovoiceWsiEntrance?wsdl",
"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\"?>"
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
LAST);
lr_end_transaction("addMenuInfo", LR_AUTO);
其中body部分就是请求内容, 可以通过抓包工具获取。
--- 以上内容转载http://softtest.chinaitlab.com/xn/794476.html
例如 soap_request():
addTask()
{
lr_start_transaction("addTask");
soap_request("StepName=addTask",
"URL=http://10.70.1.80:8080/Test/services/TestWebService",
"SOAPEnvelope="
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
"<soap:Body>"
"<addTask xmlns=\"http://server.mmap.msp.huawei.com\">"
"<in0>"
"<m0:TaskValue xmlns:m0=\"http://domain.server.mmap.test.com\">
<m0:content>webservices测试128长度!!</m0:content>
</m0:TaskValue>"
//batch-end
"</in0>"
"</addTask>"
"</soap:Body>"
"</soap:Envelope>",
"ResponseParam=response",
LAST);
lr_end_transaction("addTask", LR_AUTO);
return 0;
}