RackForms v7.8.8
http request
Site Tag Line
Latest Release: Build 958 - Arpil 18th, 2023
Contact Us  Purchase Options Purchase Options Contact Us

Top Link
Text HTTP Request

In Brief: Performs an HTTP request using GET or POST.

Dependencies: Confirmation page.

Hints & Tricks: With the right logic, you could performs all types of requests, such as credit card or PayPal processing.

Here's a great tutorial on SOAP, should you need to use that request method.

Need to send the entire form as JSON to a web service? Use the token: RF_JSON.

Debugging Web Service Calls: Debugging web service calls can be tricky without seeing what's being generated at the request level. Luckily, RackForms ships with a handy script under PHP/ASP Top Code > Simple Debug Web Service Code. Add this code to your page and follow the instructions in the top comment block to see all generated data.


Basic Attributes

Design Notes
These are notes you can input that help you and other production staff understand your confirmation elements logic and purpose. This text is never used in the live form in any way, it is only for internal development.

Confirmation/Query Condition

Confirmation Condition PHP Code

This field allows you to specify a condition which must be met for the confirmation field to be processed.

We can create code manually, or use the Condition Wizard.

Condition Wizard

If you're new to using conditions, or simply want to have RackForms generate the condition code for you, the wizard is a fast and easy way to do so. To create a confirmation condition, simply follow the wizard from top to bottom.

Start by mousing over the This Field: select item. All fields in your form will display, select the item you want to base the condition on.

Please note if we select a Checkbox field an additional select item will display, Having This Checkbox Value (optional):. This select item will display all possible values for that checkbox. Select which value you want to base the condition on. When you do, the condition process is complete.

For all other fields, the next step is to set the Must: field. This will take the value of Equal or Not Equal, and several others.

Finally, type into the This Value: box to set which value the form field we selected above will validate against.

If you want to add additional conditions, such as a name must be Equal to Steve and age less than 10, first select the Additional Condition button and start from the top of the wizard again.

Hand Coding Conditional Code

The logic takes the form of:

Variable 1 | Condition | Variable 2

For example, let's assume we have a radio item in our form with the Name/Value of opt_1. The radio item has two possible vales, 'Yes' and 'No'. If the value of opt_1 is 'Yes' we want to send an email, if no, we do not.

We would write the Confirmation Condition PHP Code as such:

#{opt_1} == 'Yes'

In other words, we use the token for our field variable like we would in other property boxes, that is, a pound sign (#) followed by the Name/Value of the field in braces. Recall that at run time this token evaluates to the value set by our forms users, which in this case will be the value of the radio button with the Name/Value of opt_1.

We then set the comparison, in this case out comparison is equal too, denoted with the double == sign. Finally, because we know our radio item is a string value that can be 'Yes' or 'No', we wrap the value we want to check for in single tick marks.

On the raw code side, RackForms wraps the token call in an isset() block, which is further wrapped in the proper PHP if() syntax:

if(isset($_SESSION['qs']["{$_SESSION['entry_key']}"]['opt_1']) && $_SESSION['qs']["{$_SESSION['entry_key']}"]['opt_1'] == 'Yes') { // condition code start

When run, if the users set value for the radio box was 'Yes', we would process this confirmation element.

Using Array Based Form Elements (Checkboxes)
PHP Treats checkbox items a little differently than other elements. The good news is the only element that needs this special attention is a checkbox field. The difference then, is that in order to use checkbox items we need to place an index indicator just after the form field name.

For example, lets say we have a checkbox field with the Name/Value: email_condition, and it has two elements: Recipient A and Recipient B

To process this field in our condition statement we append the proper index in the format of [index-number]. It's quite simple when you see it in practice:

#{email_condition[0]} == 'Recipient A'

#{email_condition[1]} == 'Recipient B'

Please note the [0] and [1]. These are the index positions of the field being checked. Compare this to a standard field token:

#{email_condition} == 'Recipient A'

A checkbox group has several items, the [0] and [1] bit tell RackForms which number item to grab.

How do we know which number to use? In our example the checkbox field has two values, and array indexs start with 0. Thus, the first field, Recipient A, is [0], and Recipient B is [1].

The rule then is our numbering simply adds 1 for every checkbox item in the group, and always starts at 0.

HTTP Request

Request Method

Choose between GET or POST and the type of request:

GET via file_get_contents(): This request method requires the allow_url_fopen .ini directive to be set to true. In some cases, your web hosting company may disable this feature for security reasons. Use your own discretion with this request type.

cURL GET - This request type uses the cURL library to perform GET request. Depending on your web hosting provider, you may need to use this method over the GET via file_get_contents()

cURL GET + Headers - This request type uses the cURL library to perform GET requests that return HTTP headers. RackForms will use this header information to automatically detect errors. RackForms will die() if the HTTP request returns anything other than 200 status.

cURL POST (Supports File Uploads < PHP v. 5.5) - Performs an HTTP POST request via the PHP_CURL extension. POST Requests are considered safer, more flexible, and a smart choice for communicating with Web Services over GET via file_get_contents() requests.

Please note that cURL post requests require that you supply a value to the Success Code box detailed below.

This method supports multi-part file uploads using PHP's CURLFile. When file items are present, they are sent to the endpoint via this API. Please note, however, this is only supported on versions of PHP that contain the CURLFile class, which means PHP 5.5 or higher.

cURL POST + Headers - Performs an HTTP POST request via the PHP_CURL extension that returns and evaluates HTTP headers. RackForms will die() if the HTTP request returns anything other than 200 status.

SOAP Request - Performs a SOAP HTTP request to the WSDL URL you specify. Form the requester side, SOAP requests are very good at taking an XML response and turning it into a native language Object, which can then be modified at will. From the Web Service creators side, SOAP requests can be tightly integrated into a structured programming environment. For example, you can take a PHP class and create a WSDL file based on that class.

Please note that SOAP requests use a different set of parameters in the RackForms editor, which are located at the very bottom of the HTTP Request field items. Also, SOAP parameters are prefixed with SOAP.

cURL + Raw XML & cURL + Raw JSON - These request are unique in that unlike many of the others, we send raw XML or JSON via an HTTP cURL request, along with the proper HTTP Header for each data type. This can be very useful for many types of processes such as payment processing.

One key item to note is if we're responsible for retrieving the content of such a request, we'll need to pull from PHP's input stream as:

$postXML = file_get_contents('php://input');

Or more verbosely and to the stout/console as:

syslog(LOG_NOTICE, stream_get_contents(fopen("php://input", 'r+' )));

We can then process the JSON or, in this case, XML, using classes like SimpleXML as:

$postXML = file_get_contents('php://input');

    $xml = new SimpleXMLElement($postXML);
} catch (Exception $e){
    echo 'ACI Response Was Not Well Formed XML.';

Treat POST Method File Uploads As

This option determines how file upload data is processed when using one of the two POST Request Methods. The default is to treat file upload data as a simple POST field. This is a very common method, as it treats file data the same as any other field.

If we're running PHP 5.5 or higher, we can also use Multi-Part Data. This method uses PHP's CURLFile class to treat file upload fields as multi-part form data. This is how upload data is treated when we POST a form in the traditional sense, and may be required for some web service providers.


The URL of the HTTP Request. For GET via file_get_contents this can be a file path path or fully qualified URL. For All other methods, this must be a full qualified URL.

Caution: If using GET via file_get_contents, if used with a local file path you'll return the raw file contents, not the processed file as a web server would return. This could be used to return sensitive information such as passwords and logins.

This value accepts several types of dynamic content, from raw PHP variables to RackForms Tokens.

To use a raw PHP variable, define said variable before the HTTP Request module, then use the standard in-line syntax of:


Tokens are much the same, only instead of using the braces outside of the variable name, we wrap the variable in the type qualifier, braces, variable name. For example, if we had the same variable above named $var, the token would be:


For other tokens we'd simply replace the $ with the token type. POST variables would use P, GET G, and so on.

Query String (Formerly Field Variables)

The HTTP Request you send will generally need variables to make it perform some work for you based on the run-time values of those items. RackForms supports two types of variables: Raw Query String and Comma Delimited List. Let's take a look at each in turn:

Important: We cannot mix and match the Query String and Comma Delimited List methods. A Web Sevice / HTTP Request call can only ever use one type.

Raw Query String

A raw query string is simply a block of formatted text composed of one or more name / value pairs. The format of these pairs is field name, an equal sign, and a value. We "join" multiple name value pairs together with an ampersand (&):

Our job as a consumer of a web service is to create and pass this query string using the values and format understood to the service. The web service we're calling will contain this information, usually in the form of an API documentation page.

Of course a web service wouldn't be of much use if we didn't have control over the value component of the name / value pair. Thus, in RackForms we create the raw query string by using dynamic tokens. We use the tokens as replacements for any field component we wsh to be dynamic. For example, if we had a form fields called name, email and we wished to use those as field variables, we'd use the F{} token:


The main benefit of this method is we have 100% control over the query string. This is in contrast to the Comma Delimited List method, where the name component is created for you.

Comma Delimited List

The second method of providing values is with a Comma Delimited List. In this method we simply supply a list of PHP or Form Field tokens. The main difference between this and the Raw Query String method is in the Query string method you're responsible for creating the name value pairs in the correct format.

In this method we simply supply a list of field elements to pass to the query and RackForms builds the query string for you. It's key to note the output, as far as the web service is concerned, is the same -- a query string. The critical tradeoff however is the list method doesn't allow us to define the name part of the name value pair.

That is, RackForms will simply take the name of the field token and use that as the name element of the name value pair. For example, if we used: F{name}, the resulting string would be: name=F{Name}

To ease in development time use the Dynamic Variable Picker to display a valid list of field elements and their variable names for you.

Regardless of which method we use to populate the Field Variables box, as an example let's say in our RackForms form we have two text fields that have Name/Values of <name> and <age>. We would thus set the value of the Field Variables as:


RackForms will then process these variables at form submission time and send the result using the Request Method you specify. Of course to save you work RackForms automatically creates a URL Encoded string for you using the field name + dynamic values. For example:


PHP Variables

We can also supply the Field Variables list with local PHP variables. To do so we insert the PHP variable name without the dollar sign wrapped up in a token in the format of:


For example, let's say I create a PHP variable like so and place it into the Page PHP Top Code text box: ** (please see note 1 just below)

$text1 = 'tester text 1';

To retrieve this variable at run time, I would use the following text in my Field Variables text box:


Notice we do not use a dollar sign in the variable name e.g., we use ${text1} not ${$text1}

Other Variables

Starting with Build 677, we can now use the full compliment of RackForms tokens to populate our variables list.

** Note 1 - Using the Page PHP Top Code box is very important when dealing with the HTTP Request module because by default, the PHP code you type into the other main PHP code box, Page PHP Head Code, is placed after the HTTP Request code. That means in order to use PHP variables with the HTTP Request module in the Field Variables list, that code must be placed into the Page PHP Top Code box.

Meta Data and HTTP Requests

In addition to field item values, RackForms also allows you to use several meta items to capture commonly used data. The available meta set for the HTTP Request item is:

SESSION_ID - Capture the internal PHP session_id.

TIMESTAMP - Returns a UNIX epoch timestamp.

DATETIME - Returns a timestamp in the format of 'Y-m-d H:i:s'.

REMOTE_ADDR - Calls $_SERVER['REMOTE_ADDR'] to return the visitors IP.

RF_JSON - Serialize the entire form as JSON.

RF_JSON is very handy for times when we wish to have third-party services process our form submission. Please note this serializes the entire form, which will include any file uploads, GEO data, and login meta information.

Please note the content of this data is encoded into UTF-8 before being serialized with PHP's built in json_encode() function call. For text data this conversion can generally be ignored, but this does have a profound effect on binary data, such as will be contained for image uploads and signature image data. If we're including file data in the form and sending it using this method, please note our receiving program will need to run a utf8 decode method on the data first before it will be usable.

To use any of these meta items, just type the name out as shown in this list in the 'Field Variables' text area box, just as you would any other field item. Be sure to separate each with a comma.

Debugging RF_JSON calls
When building a sample form and you wish to see the result of this call, we can build a receiving page (endpoint) that pulls from php://input.

For example:

$raw = file_get_contents('php://input'); // get raw input stream data
echo $raw; // print it out

// JSON To PHP Object
$obj = json_decode($raw);

if($obj != null){
  echo 'Raw value of RF_JSON Token';

  // Pull zip field from result
  echo 'Postal/Zip Code Field Value From RF_JSON' . $obj->postal_code;
} else {
  echo 'No RF_JSON Data Present, Skipping.'; 


Success Code

RackForms uses the value of this field to validate the status of your HTTP request though a simple boolean comparison. The result of this comparison determines what action path is followed: On Success or On Fail.

Please note this is a required field for the cURL methods. This means even if your HTTP Request does not return a value, you still need to supply one. A simple '1' (without quotes) will do as a dummy value.

On Success: $response = success code

If you supply a value to the Success Code field and the result of your HTTP request is equal to that value, this field will be processed. It is important to note the value of this field must be PHP code. See Sample Code 1 for an example.

On Fail: $response != success code

If the comparison between the Success Code and the HTTP request fails, the code in this field is processed, as your request has 'failed'. It is important to note the value of this field must be PHP code. See Sample Code 1 for an example.

Sample Code 1
if($response == 1) {
  echo 'pass';
} else {
  echo 'fail';

In the example above, we can see that if the $response variable, which is the internal value of the GET or POST request response, is equal to 1, the script echo's 'pass' to the page, or 'fail', if not.

Custom Request Response Logic

If you provide any value in this box, this text will be used as the 'logic code' for any HTTP request, in that after the request finishes and the value of the HTTP request is passed into the $response PHP variable, this code will be inserted into your page and run by PHP.

For example, we could simply copy/paste the code example from above:

if($response == 1) {
  echo 'pass';
} else {
  echo 'fail';

Into our Custom Request Response Logic box and when run, this will be the code that is executed by PHP immediately after the HTTP request finishes.

HTTP Example / Web Service Requests

You can use the http request field item to perform Web Service requests. For example, we can use the Yahoo Image Search REST service via a RackForms form to return a listing of images relating to a search query.

First, download this RackForms xml job file.

Load the job in to RackForms and export it. By default, it will perform a Web Service Request to the Yahoo service and return an XML data page.

Now click on the HTTP Request item in the confirmation page and notice how we have our fields set.

Note how we are using the cURL POST + Headers request method, which means in our 'Custom Request Response Logic' we bypass the headers with:

if (!($xml = strstr($response, '<?xml'))) {
$xml = null;

And then echo out this xml.

We can use a request method that does not use HTTP headers just as easily by selecting such a type from the Request Method drop down menu.

You can extend this logic to consume more advanced web services, such as credit card payment processing.

Show Debug output

This option will show raw request information on the form page.

cURL: URL Encode cURL Variables/Request

This option will URLEncode your cURL request variables when using cURL GET or POST, and the entire request when using cURL + Raw JSON/XML. For raw requests this option is usually not needed, but could be helpful in some cases.

cURL: SSL Verify Peer

This security option may be needed when connecting to some hosts.

Custom cURL Options Code

This code block applies a cURL header to your request. The format of this code differs based on which Request Method we're using.

For all types except cURL + Raw XML and cURL + Raw JSON, we use curl_setopt calls in the form of:

curl_setopt($ch, CURLOPT_USERPWD, 'username:password'); // Your credentials here

In this example we're adding an authorization header as defined here. Note the use of the $ch variable. This is the main container RackForms uses for such calls, and must also be used in any custom header calls you create.

For cURL + Raw XML and cURL + Raw JSON we MUST start our code with a comma (,), followed by a comma-delimited list of string items. For example:

'Content-length: 0',
'Authorization: OAuth ' . $accesstoken

Be aware: these two methods send custom headers matching the data type they're sending, and thus may not work with custom headers like Authorization.

Also be aware that we cannot define variables in cURL + Raw XML and cURL + Raw JSON mode, we can only access them. Thus, in our example above we take it to mean $accesstoken has already been defined.

SOAP Options


This is the url of the WSDL file you intend to query against.

SOAP Method Name

All SOAP calls must call a method, this is the name of the method you are calling. You do not need to include any text other than the method name.

If you're unsure of the method names the service defined in the SOAP WSDL URL supports, you can always toggle on SOAP Debug: Show Functions (see below) to echo out the list of functions this service returns. That said, we still need to place some text in this field, as if left empty it will cause a PHP error.

SOAP Parameters

This is the comma delimited list of parameters you wish to pass to the SOAP Request.

Updated in Build 706, internally we now pass the name of the parameter as well as its value. This means the SOAP service MUST use named parameters, and those in turn MUST match the Name/Value property of the RackForms form element being used as the driver for that parameter.

For example, if your SOAP call requires a parameter of symbol, we must use that as the Name/Value property of the form field.

Custom SOAP Response Logic

New to Build 706, this feature lets us add custom processing code to manage the SOAP response. This will not always be needed, but if so, we have four convenience variables created for us:


This value represents the stdObject automatically created for us by the PHP soap client. This object will typically hold one string property which is the processed XML of the SOAP response. The name of this property (and this is important!) is defined by the WSDL file of the web service being called. That is, if the web service returns a value, it will be defined in the WSDL file by name.

These names generally follow the convention of using the same name as the SOAP method being called plus the word 'result'

So for example, in the SOAP demo in the Load Example Job menu of the RackForms editor, the method we call is:


Which means the XML string property we call for $soap_response is:


Knowing this function name is the key to processing the XML result. If in doubt, check the WSDL file!


This variable represents an attempt to instantiate a new SimpleXMLElement against $client->__getLastResponse(). Unfortunately the validity of this call may not always be acceptable.

This is because it appears PHP will not always properly parse the XML string being returned, which means any xpath calls will subsequently fail.

The problem seems to be the < > characters are not processed and instead set as non-entities. It is for this reason we have the $soap_xml_fixed variable, detailed below.

Regardless, if it's the raw value we need use $soap_raw or $soap_raw_fixed. If we want to use a SimpleXML object instead and we're sure it's been processed correctly by PHP, use this guy.


As described above, PHP's SOAP implementation does not always seem to process the raw XML return data properly from a call to:


The end result is xpath calls will not work, meaning we cannot access our return data.

This variable thus runs a str_replace() on the data before being run against SimpleXMLElement(). This should fix any of our string problems and return a fully-functional SimpleXML object.

We can then use this object to perform xpath queries against, or any other operation where we manipulate and read XML data.


This variable is set via a direct call to: $client->__getLastResponse(). Thus, it represents the purest form of SOAP response, in that no processing has been performed on the data.

As such, this means it's also the most challenging to work with, as we'll need to call any needed registerXPathNamespace() functions on our own. The upshot of course is this may be needed for more complex result processing.

As an example of what's required for working with such raw data, lets assume the following XML return value:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.rackforms.comw3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.rackforms.comw3.org/2001/XMLSchema">
<GetQuoteResponse xmlns="http://www.rackforms.comwebserviceX.NET/">
<AnnRange>120.61 - 173.54</AnnRange>
<Name>International Bus</Name>

The first thing to note is the use of namespaces in the XML file. This means we'll need to call registerXPathNameSpace() to create a link between the prefix and the namespace. Namespaces in SOAP responses are quite typical, and we'll need to have a good understanding of them as well as XPATH to make any headway in dealing with a raw response like the one above.

As a brief overview however, in this case, the proper entry point would be on the Default Namespace defined for GetQuoteResponse. We set the link to 'b', which means our xpath query becomes:


Which means: for the namespace b (which is an alias for http://www.rackforms.comwebserviceX.NET/), start at the current node and match at any point an element called Last. In this case, Last is the current stock price.

A typical PHP code block that performs this logic would be:

$fixed_xml = $client->__getLastResponse(); 
// fix the xml data
$fixed_xml = str_replace('&lt;', '<', $fixed_xml);
$fixed_xml = str_replace('&gt;', '>', $fixed_xml);
// create the SimpleXML object...
$soap_xml = new SimpleXMLElement($fixed_xml);
// register (alias) the namespace b to the GetQuoteResponse prefix $soap_xml->registerXPathNamespace('b', 'http://www.rackforms.comwebserviceX.NET/');
// now use the b prefix to call Last
$result = $soap_xml->xpath("//b:Last");
Please note the fixer code where we replace the &lt; and &gt; strings with their proper HTML entities. Not doing so would mean the xpath query would not work.

SOAP Debug: Show Functions

So long as you have a proper SOAP WSDL URL defined, you can toogle this field on to return a list of valid method names. You can then use that list to properly query against the service.

SOAP Debug: Show Returns

Toggle this on to view the raw XML returned from the Web Service call.

SOAP Debug: Show SOAP Method Call Errors

This feature, introduced in Build 706, allows us to catch any method call errors. This is handy when debugging a newly created web service call, or when nailing down the parameters we're passing to it from RackForms.

Socket Timeout

This feature, also introduced in Build 706, allows us to lower the servers socket timeout value via a PHP ini_set call of:

ini_set ( "default_socket_timeout", 60);

This is very important for debugging SOAP calls, in that in most default instances the server execution timeout limit will be reached before the socket_timeout, which means we never actually get errors returned from the SOAP Debug: Show SOAP Method Call Errors setting.

This is also a very handy way to speed up debugging of SOAP calls, as the default values of 30 or 60 for most servers are much longer than actually needed.

The default value for production forms should be 30 or 60, and a good debug value is 3. This value is in seconds.

SOAP Tutorial
Constructing and calling a SOAP Web Service can be a rewarding experience. SOAP calls, while initially foreign and complex, are actually very powerful and useful tools in the PHP development world.

At the most basic level, SOAP requests are a platform independent method for querying a remote method for information. The platform independence comes from the fact that at their heart, SOAP calls are based on the ultimate platform independent format: XML. Even better is that if you only need to call a SOAP request as opposed to building it too, a server running PHP can call a Web Service hosted on .NET by setting as little as two parameters!

In this quick guide, we'll get you set up with your first SOAP request using the RackForms editor.

First, create a Sortable form page and place a single text field on it. Set the Default Value of the text box to be ibm.

Now add a submit button.

Now create a Confirmation page and add a HTTP Request module to it. click the HTTP Request item and select SOAP Request from the Request Method drop-down box. Let the SOAP fun begin!

While a SOAP Web Service call can be constructed on the fly, this is generally the most complex and least flexible way to go about this task. That's where WSDL files come into play.

A WSDL file is an XML formatted specification for the SOAP Request/Response that is created by who ever designed the Web Service. A WSDL file basically tells the calling client what methods are available, what types of parameters are accepted, and so forth. WSDL files only need to be created once, after that you can call the WSDL file to perform the Request/Response as many times as needed. It is important to note that you are not creating WSDL files in RackForms, your are only querying them.

That is why the first and most important part of the SOAP building process in RackForms is the designation of the SOAP WSDL URL.

For the purposes of this tutorial, I have created the proper WSDL file which defines a Web Service on the www.rackforms.com site at:


Place this full address into the SOAP WSDL URL text box.

Generally speaking, you will already know the name of the method you need to call, which means you would have a value to place into the SOAP Method Name box. In this case however, we do not know it, so we'll query the Web Service first to get a list of methods.

To do this successfully though, we need to place a dummy value into the SOAP Method Name text box. test will do fine. if we do no place a value into this box, we will get an error on our page and the method name request will fail.

Click the checkbox under: SOAP Debug: Show Functions to turn on the debug display which will show our method names. Build the form and click submit on page 0. When the confirmation page loads we should see this at the top:

Array (

 [0] => string getWord(string $word)

 [1] => string getQuote(string $symbol)


This is our handy list of method names the WSDL file defines for us. It tells us that this Web Service has two methods: getWord and getQuote.

We now have what we need to place the proper value into the SOAP Method Name text box. Let's try getQuote first. Place the text getQuote into the SOAP Method Name text box.

Next we need to define the parameter we'll pass into the Web Service call. getQuote takes a single string value, which in this case, will be the ibm we placed into our text field's Default Value on the first page of our job.

Thus, click the Dynamic Variable Picker link just under the SOAP Parameters text area, you should only have one, text1, click it!

And that's it. Our SOAP Request now has everything it needs to return a value.

To make sure everything works though, we'll uncheck all SOAP Debug boxes, then enter this code into the Page PHP Head Code of our Confirmation Page:

echo $soap_response;

By default, RackForms sticks any SOAP response into a PHP variable named $soap_response.

Alright, let's build our page and try it out. If all goes well you should see 98.45  at the top of the page, which is the value the getQuote method returns no matter what.

Wrapping Up

Finished! From this point on it's really about you finding the WSDL URL for a web service, populating the methods and parameters, and working with the return values.

As an exercise for the reader, remember that we have two web service methods available, we've tried one, now try the other! If you prefer, you can also download the job XML file for this demo.

So many features, So little time