webservice 报文post传递

http接口报文如何发送
参考:http://bits00.iteye.com/blog/1634698
实际上,使用LR还有一种测试WebService的方式,就是采用HTTP协议,因为WebService是构建在HTTP协议之上的,因此可以WEB虚拟用户协议中的web_custom_request来构造WebService的请求。

Action()
{
web_reg_save_param("Response","LB=", "RB=", LAST);
web_add_header("SOAPAction", "SampleMethod");
lr_start_transaction("REQ");
web_custom_request("Sample_Request","Method=POST",
"Mode=HTML",
"RecContentType=text/xml",
"EncType=text/xml; charset=utf-8",
"URL=http://example.com:1234/sample/",
"Body=<Envelope xmlns=\"http://example.com/sample\">\n"
" <Header/>\n"
" <Body>\n"
" <price><id>001</id></price>\n"
" </Body>\n"
"</Envelope>",
"LAST");
lr_end_transaction("REQ", LR_AUTO);
lr_output_message("Response is : %s\n", lr_eval_string("{Response}"));
return 0;
}

自己的代码
请求的url: http://esbpre.******.com:9106/SuNingServiceWeb/mb
消息:
<MbfService xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><input1><MbfHeader>
<ServiceCode>SuperKeyMgmt</ServiceCode>
<Operation>queryBindRelationforPhone</Operation>
<AppCode>EPP</AppCode>
<UId>361cbc5c2812465f85f9911b791f87d92ba765e466cc4d2a</UId>
<AuthId>EPP;hI35ixh@tR%j</AuthId>
</MbfHeader><MbfBody><YLReq>
<transactionId>SNYFB001201507211513431000147944</transactionId>
<account>0000000000002017066</account>
<reqAcct>SNYFB001</reqAcct>
<reqKey>12qw!@</reqKey>
</YLReq></MbfBody></input1></MbfService>
代码:
Action()
{ lr_start_transaction("cloud");
web_reg_find("Fail=NotFound",
"Search=All",
"Text=<resCode>8006</resCode> ",
LAST);

web_add_header("Content-Type","application/soap+xml; charset=utf-8");

web_custom_request("web_custom_request",
"URL=http://esbpre.****.com:9106/SuNingServiceWeb/mb",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"Body=<MbfService xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><input1><MbfHeader>"
"<ServiceCode>SuperKeyMgmt</ServiceCode>"
"<Operation>queryBindRelationforPhone</Operation>"
"<AppCode>EPP</AppCode>"
"<UId>d00883250a074ee984edb677cc731153a8d79add06224006</UId>"
"<AuthId>EPP;hI35ixh@tR%j</AuthId>"
"</MbfHeader><MbfBody><YLReq>"
"<transactionId>SNYFB001201406110850101000038468</transactionId>"
"<account>{ACCOUNT}</account>"//6009151496
"<reqAcct>SNYFB001</reqAcct>"
"<reqKey>12qw!@</reqKey>"
"</YLReq></MbfBody></input1></MbfService>",
LAST);

lr_end_transaction("cloud", LR_AUTO);
return 0;
}

说明:
http接口的html消息发送,1.选择post方式,2.加头web_add_header("");声明后面要传html消息;3.body内填写完整的html消息。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值