First, by grasping the packet to obtain the code stream message of an interface, request message Code sub-message header and message body, so in the production of scripts also need to add the message header and message body.
post/jboss-bet/services/&** http/1.1
SOAPAction: ""
Content-type:text/xml; Charset=utf-8
host:10.0.0.0:8080
Connection:close
content-length:1004
<?xml version= "1.0" encoding= "Utf-8"?>
<soapenv:envelope xmlns:soapenv= "http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc>
<soapenv:Body>
<NS1: Request Xmlns:ns1= "http://ww.***.com" >
<event>
<portalaccount xsi:type= "Xsd:string" >admin</portalAccount>
<portalpwd xsi:type= "Xsd:string" >123456</portalPwd>
</event>
</ns1:**>
</soapenv:Body>
</soapenv:Envelope>
Message headers can be added with Web_add_header or Web_add_auto_header functions, 2 functions are only in different positions, Web_add_auto_header can be placed in init or action, and web_add_ The header can only be placed in action.
Web_add_header ("Content-type", "text/xml;charset=utf-8");
Web_add_header ("Host", "10.0.0.0:8080");
The body of the message can be added using the Web_custom_request function.
Web_custom_request ("* *",--Custom request name, easy to understand
"url=http://10.0.0.0/8080/jboss-bet/services/&**",
"Method=post",
"Resource=0",
"Referer=",
"Mode=http",
"Body"
--Message body
"<?xml version= \" 1.0\ "encoding=\" utf-8\ "?>"
"<soapenv:envelope xmlns:soapenv=\" http://schemas.xmlsoap.org/soap/envelope/\ "xmlns:soapenc>"
"<soapenv:Body>"
"<ns1:** xmlns:ns1=\" http://ww.***.com\ ">"
"<event>"
"<portalaccount xsi:type=\" xsd:string\ ">admin</portalAccount>"
"<portalpwd xsi:type=\" xsd:string\ ">123456</portalPwd>"
"</event>"
"</ns1:**>"
"</soapenv:Body>"
"</soapenv:Envelope>"
)
Note Here is the message body, in the message stream quotes "", in the LoadRunner is not recognized, you must precede the quotation marks with the \ symbol, which is the form: \ "\".
At this point, the script is finished.
Let's talk about the connection.
Web_reg_save_param ("Miyi", "lb=<returncode>", "rb=</returncode>", last);
This is a simple association, what is it associated with?
Read the text all know, the request is followed by the corresponding, and the LR simulation is the request, but often many times, the next request after a request needs to be based on the first request to give the corresponding dynamic code for the second request, so this time we use the association. Look at the following example:
Lr_output_message (Lr_eval_string ("{Miyi}")); if (strcmp (lr_eval_string ("{Miyi}"), "00000") = = 0) { lr_end_transaction ("login", Lr_pass); } else{ lr_end_transaction ("login", lr_fail);
You can also write a checkpoint with the association, you can also try it.
Add one more test point:
Web_reg_find ("text=wangyuxing", "Savecount=yw", last);
How do you judge it?
if (Atoi (lr_eval_string ("{yw}") >0) { lr_output_message ("Wangyong: OK !"); } else{ lr_output_message ("Wangyong: no !"); }
(Transferred from Http://www.cnblogs.com/Javame/archive/2013/03/18/2965588.html)
LR hand-crafted WebServices interface class script