WebFormGet Function

Action

Sends the form content to the Web server. The form content is transformed into a single string that is appended to the URL. The URL defines the file to be retrieved from the Web server using the HTTP GET method. If the form includes a random variable, this function selects a new random value each time the form is posted.

Include file

WebAPI.bdh

Syntax

WebFormGet(
  in sUrl : string,
  in formUrl : form,
  in fWait : float optional): boolean;

Return value

  • true if the worker thread communicating with the server could be started successfully

  • false otherwise. The return value will not inform about any Web traffic-related problems due to independent threaded operation.

Parameter Description
sUrl Complete URL to the file on the server
formUrl Form identifier used in the dclform section (see example below). The expanded form string is appended to the URL after the "?".
fWait Minimum time or minimum mean time that this function call has to last (optional). Default value is 0.0

The form content in the dclform section is represented in an unencoded format to enhance readability and customizability. The data gets URL encoded on form submission. There are two possibilities to send data unencoded:

  • Add the query string as it should be sent to the server directly to the URL, for example, http://www.comp.com/cgi/special?dont encode blanks

  • Use WebUrlPostBin or WebFormPostBin to post data as provided to the Web server.

Example

var
  nWait : float;
  sName : string(100);
dclrand
  rnWait : RndExpF(5.0);
  rnPhone : RndStr("0123456789"; 16..16);
  rsAddress : RndFile("Address.rnd", 100);
  rsFName : RndFile("gfname.rnd", 20);
  rsLName : RndFile("glname.rnd", 20);
dcltrans
transaction TWebFormGet
begin
  // Get a random full name
  sName := rsFName + " " + rsLName;
  // and a random think time
  nWait := rnWait;
  WebFormGet("http://standardhost:2080/data2html.asp", FORM_01, nWait);
end TWebFormGet;
dclform
  FORM_01:
    "name" := sName,
    "address" := rsAddress,
    "phone" := rnPhone;

Sample scripts

WebForms01.bdf, WebForms03.bdf, WebForms04.bdf, WebMeasure01.bdf, WebMulti01.bdf, WebParseResponse01.bdf