使用HTTP协议进行SOAP模拟
上一篇 / 下一篇 2012-07-24 10:50:33 / 个人分类:原创
Action()
{
int num ;
{
int num ;
int maxlens =27344150;
//soap消息http请求头中的字段--服务器地址
web_add_header("SOAPAction", "http://10.40.33.19:38090/nvsauc/services/cmccSOAP");
web_add_header("SOAPAction", "http://10.40.33.19:38090/nvsauc/services/cmccSOAP");
web_set_max_html_param_len("27344150");
//保存响应用于分析返回结果
web_reg_save_param("rcontext","LB=","RB=","SEARCH=BODY",LAST);
web_reg_save_param("rcontext","LB=","RB=","SEARCH=BODY",LAST);
//模仿soap消息请求
web_custom_request("CVRequest",
"Method=POST",
"Mode=HTML",
"RecContentType=text/xml",
"EncType=text/xml",
"URL=http://10.40.33.19:38090/nvsauc/services/cmccSOAP",
"Body=<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
"<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'"
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
"<SOAP-ENV:Body><tns:CVRequest xmlns:tns='http://www.cmcc.com/cv/'>"
"<Version>1.0</Version><MsgType>AUTH_ADC</MsgType><MsgSeq>00000001</MsgSeq>"
"<TimeStamp>20110125184544</TimeStamp><CVBody><Msg_Body><"
"EcCode>8888800001</EcCode><"
"UserName>{NewParam}</UserName>"
"<Password>000000</Password>"
"<ClientType>1</ClientType></Msg_Body>"
"</CVBody></tns:CVRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>",
LAST);
web_custom_request("CVRequest",
"Method=POST",
"Mode=HTML",
"RecContentType=text/xml",
"EncType=text/xml",
"URL=http://10.40.33.19:38090/nvsauc/services/cmccSOAP",
"Body=<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
"<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'"
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
"<SOAP-ENV:Body><tns:CVRequest xmlns:tns='http://www.cmcc.com/cv/'>"
"<Version>1.0</Version><MsgType>AUTH_ADC</MsgType><MsgSeq>00000001</MsgSeq>"
"<TimeStamp>20110125184544</TimeStamp><CVBody><Msg_Body><"
"EcCode>8888800001</EcCode><"
"UserName>{NewParam}</UserName>"
"<Password>000000</Password>"
"<ClientType>1</ClientType></Msg_Body>"
"</CVBody></tns:CVRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>",
LAST);
//解析响应
lr_xml_get_values ("XML={rcontext}",
"Query=/Envelope/Body/CVResponse/CVBody",
"ValueParam=OutputParam",
LAST);
lr_xml_find("XML={OutputParam}",
"Query=/MSG_BODY/AuthResultCode",
"Value=0",
LAST);
"Query=/MSG_BODY/AuthResultCode",
"Value=0",
LAST);
lr_xml_get_values ("XML={OutputParam}",
"Query=/MSG_BODY/Token",
"ValueParam=Token",
LAST);
"Query=/MSG_BODY/Token",
"ValueParam=Token",
LAST);
lr_output_message(lr_eval_string("{rcontext}"));
lr_output_message(lr_eval_string("{OutputParam}"));
lr_output_message(lr_eval_string("{Token}"));
web_add_header("SOAPAction", "http://10.40.33.19:38090/nvsauc/services/cmccSOAP");
//模仿soap消息请求
web_custom_request("CVRequest",
"Method=POST",
"Mode=HTML",
"RecContentType=text/xml",
"EncType=text/xml",
"URL=http://10.40.33.19:38090/nvsauc/services/cmccSOAP",
"Body=<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
"<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'"
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
"<SOAP-ENV:Body><tns:CVRequest xmlns:tns='http://www.cmcc.com/cv/'>"
"<Version>1.0</Version><MsgType>HEARTBEAT</MsgType><MsgSeq>00000001</MsgSeq>"
"<TimeStamp>20110125184544</TimeStamp><CVBody><Msg_Body><"
"Token>{Token}</Token><"
"Source>0</Source>"
"</Msg_Body>"
"</CVBody></tns:CVRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>",
LAST);
web_custom_request("CVRequest",
"Method=POST",
"Mode=HTML",
"RecContentType=text/xml",
"EncType=text/xml",
"URL=http://10.40.33.19:38090/nvsauc/services/cmccSOAP",
"Body=<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
"<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'"
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
"<SOAP-ENV:Body><tns:CVRequest xmlns:tns='http://www.cmcc.com/cv/'>"
"<Version>1.0</Version><MsgType>HEARTBEAT</MsgType><MsgSeq>00000001</MsgSeq>"
"<TimeStamp>20110125184544</TimeStamp><CVBody><Msg_Body><"
"Token>{Token}</Token><"
"Source>0</Source>"
"</Msg_Body>"
"</CVBody></tns:CVRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>",
LAST);
//聚集集合点
lr_rendezvous("authadc");
//开启事务
lr_start_transaction("webplay");
lr_start_transaction("webplay");
//保存响应用于分析返回结果
web_reg_save_param("nvssgwreq","LB=","RB=","SEARCH=BODY",LAST);
//soap消息http请求头中的字段--服务器地址
web_add_header("SOAPAction", "http://10.40.33.19:48090/nvssgw/services/cmccSOAP");
//模仿soap消息请求---web 获取设备列表
/** */
web_custom_request("CVRequest",
"Method=POST",
"Mode=HTML",
"RecContentType=text/xml",
"EncType=text/xml",
"URL=http://10.40.33.19:48090/nvssgw/services/cmccSOAP",
"Body=<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
"<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'"
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
"<SOAP-ENV:Body><tns:CVRequest xmlns:tns='http://www.cmcc.com/cv/'>"
"<Version>1.0</Version><MsgType>WEB_PLAY_LIST</MsgType><MsgSeq>00000001</MsgSeq>"
"<TimeStamp>20110125184544</TimeStamp><CVBody><Msg_Body><"
"EcCode>8888800001</EcCode><"
"Area>01</Area><"
"UserName>{NewParam_1}</UserName><"
"Token>{Token}</Token>"
"</Msg_Body>"
"</CVBody></tns:CVRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>",
LAST);
lr_output_message(lr_eval_string("{nvssgwreq}"));
lr_xml_get_values ("XML={nvssgwreq}",
"Query=/Envelope/Body/CVResponse/Result",
"ValueParam=Result",
LAST);
num = lr_output_message("%d", lr_output_message(lr_eval_string("{Result}")));
if(1==num)
{
lr_output_message("成功!");
lr_end_transaction("webplay", LR_PASS);
}
else
{
lr_output_message("失败!");
lr_end_transaction("webplay", LR_FAIL);
}
return 0;
}
}
相关阅读:
- Loadrunner11之VuGen之HTTP页面常用函数 (十一) (零测试, 2011-11-05)
- http 错误代码表 (Amei595409929, 2011-11-30)
- JMeter初体验——问题记录2(HTTP请求中文乱码问题) (fairylly, 2012-6-18)
- HTTP Status 500 解决1 (jwzhangjie, 2012-6-23)