Use of the Webload script

Source: Internet
Author: User

webload for simulating an HTTP request, it is generally composed of the following three parts, and the three parts are wrapped in a transaction (from Begintransation to endtransaction): 1. Request Header or Cookiea) The request header, which is the header that accompanies the HTTP request, typically requires a header that is more than one, and is composed of the following methodswlhttp.header["key"] = "value"For example, RPS2 project requests all need to add a special head "when calling RPS2, the for every call, you must also include an HTTP header with X-product-code:r Etail_phoenix ", so the head of this request is:wlhttp.header["X-product-code"] = "Retail_phoenix"b) Cookies, sometimes sending an HTTP request requires a cookie that contains a login or user information, and when a request with a cookie is not recorded by the WL, it is necessary to manually add the code, and the method of adding the cookie is wlcookie.set (name, value , domain, path [, expire]) example, RPS requires a request that contains a mstar= v63lp207k0564o7267263n3512p365o6kol18ol2l034kl0282053275mp80k705174698mm58n744989882n19432nkm66568ll4759nm2n155l1l974n0pm 814k11939010301fc24d5b90d6fbca6ec18c7eec8 cookie, the method of invoking the cookie is:wlcookie.set ("MStar", " v63lp207k0564o7267263n3512p365o6kol18ol2l034kl0282053275mp80k705174698mm58n744989882n19432nkm66568ll4759nm2n155l1l974n0pm 814k11939010301fc24d5b90d6fbca6ec18c7eec8 "," http://scdispqaweb.morningstar.com ","/"," "),where a cookie can be placed in a TXT file and then parameterized, then there is wlcookie.set ("MStar", Datamap_cookie.getvalue (), "Http://scdispqaweb.morningstar.com ","/"," ")Note: Once made a mistake, that is, put the cookie in the request Header, that is, using wlhttp.header["cookie" = "mstar= ..."  2. Request content (and content type)sending HTTP requests, especially post requests, typically sends some request content or submits some forms. WL provides three ways to submit a form or send a request bodya). FormDataFormData properties that belong to Wlhttp objects can be used in two formats,wlhttp.formdata["key"] = "value"orWlHttp.FormData.key = "value" example,wlhttp.formdata["Login"] = "[email protected]"wlhttp.formdata["Password"] = "Mstar123"orWlHttp.FormData.Login ="[Email protected]" WlHttp.FormData.Password = "Mstar123"note:the Difference is thatThe wlhttp.formdata["key"] notation also supports spaces in the name, for example,wlhttp.formdata["First Name"].b). DataThis method is used To Submit a string that is not a standard HTML form and cannot being represented by FormData. It has the subfields:data.type–the MIME Type for the submissiondata.value–the string to submitlike FormData, it can also be expressed in two ways:WlHttp.Data.Type = "value";wlHttp.Data.Value = "Value"; orwlhttp.data["Type"] = "value"wlhttp.data["value"] = "value" Example:WlHttp.Data.Type = "application/x-www-form-urlencoded"wlHttp.Data.Value = "[Email protected]&strpassword=mstar123&login=1&rbtn=btnemail&rnd= (New Random ()). Nextdouble (). ToString () &productcode=awsoe&productid=awsoe "orwlhttp.data["Type"] = "application/json; Charset=utf-8 "wlhttp.data["Value"] = "{\" name\ ": \" Tom weng\ ", \" Number\ ": 1024x768, \" title\ ": \" QA engineer\ "}" Note: When using the Data aspect, the Value property is required, i.e. must have data["value"] or Data.value c). Datafiledatafile's role is mainly: when the request of the POST request body content is too large, in order to facilitate the maintenance of the script, the request content into an external file, and then through datafile this method to import external files. Instead of having to put a whole large POST request into the script.in the same way, DataFile supports two types of expression:WlHttp.DataFile.Type = "value";wlHttp.DataFile.Filename = "value"orwlhttp.datafile["Type"] = "value"; wlhttp.datafile["Filename"] = "value" Example:wlhttp.header["X-api-userid"] = "D5B04F19-E16B-4963-A6C1-FAAC4624FB48"wlhttp.header["X-api-productid"] = "Direct"WlHttp.DataFile.Type = "Application/json; Charset=utf-8 "//wlhttp.datafile.filename = "D:\\load test\\tom\\datafiletest\\datafile.txt"wlhttp.datafile["Type"] = "application/json; Charset=utf-8 "wlhttp.datafile["Filename"] = "D:\\load test\\tom\\datafiletest\\datafile.txt"wlhttp.post ("http://api-data-stg.morningstar.com/v2/lists") in the above example, I put the POST request content (JSON format) into a TXT file called datafile, and then through WlHttp.DataFile.Filename this method to introduce the file.   ContentType: Description: Specifies the content type of the HTTP request.The note:content type can be used as a request header field, or as a wlhttp property alone .wlhttp.header["Content-type"] = "APPLICATION/X-AMF"Wlhttp.contenttype = "application/x-www-form-urlencoded"  3. RequestGeneral HTTP requests are: Get,post,put, Delete .... The WL provides these methods and belongs to the Wlhttp object.wlhttp.get ("URL");wlhttp.post ("URL");wlhttp.put ("URL");wlhttp.delete ("URL")Example:wlhttp.get ("http://www.baidu.com")wlhttp.post ("Http://mcsvqaap-cloud.morningstar.com/DataService/api/v2/entity/columnsets")wlhttp.put ("http://api-data-stg.morningstar.com/v2/columnSets/" + idmap_columnset_id.getvalue ())wlhttp.delete ("http://api-data-stg.morningstar.com/v2/columnSets/" + corr_morningstar_columnsetid_3)  ValidationFinally, the verification

Use of the Webload script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.