Extended HTTP Requests

DETAILS: Extended HTTP Requests

(Details - Use - Extend)

Details

This building block enables the execution of HTTP requests from ADOxx or an ADOxx based modelling tool using AdoScript. It provides several procedures, which allow to perform a variety of different options to access resources and services. The procedures use several parameters to handle things like credentials, headers, the content body and response code for both requests and their responses.

Have a look at the following video/screencast to to see the building block in action! For more information on the application, please visit http://austria.omilab.org/psm/content/bee-up/info?view=scenarios

How does it work?

This implementation uses a Dynamic Link Library (DLL), which is called by the provided AdoScript procedures. As such the actually HTTP request is performed from the DLL and the AdoScript procedures provide a neat interface to the DLL. The DLL has been compiled using Free Pascal and some of its units/libraries.

Features and Functionality

The following features are provided by this building block:

  • Perform synchronous HTTP calls to Web resources, services etc. using any desired HTTP method (GET, PUT, POST, DELETE, etc.) from AdoScript
  • (Almost) complete freedom about the sent request headers and body.
  • Use of basic authentication (username and password) during the request supported.
  • Receive the response body in one of three formats: as a string, as a base64 encoded string (necessary when the response contains NUL bytes, e.g. PNG images) or as an array of bytes.
  • Additional support functions for performing HTTP calls (e.g. URL encoding of text)

 

Simply put this building block is a courier for HTTP messages. So while it is possible to also call SOAP based web services, the creating and parsing of the SOAP Envelopes has to be taken care of elsewhere.

Technical Setup

The following image shows the components and their interaction when performing an HTTP call.

The Custom AdoScript is the part that uses this building block. It wants to access something from the Web, Internet or any kind of accessible network using the Hypertext Transfer Protocol. To achieve this it invokes the provided AdoScript procedures.

The Building Block AdoScript Procedures is the AdoScript provided with this building block. It makes several procedures available to simplify calling the DLL, like using AdoScript maps to handle the HTTP request/response headers.

The ADOxx / ADOxx Modelling Tool is the environment where the AdoScripts are executed and which handles the details of calling the DLL and receiving the result among other things, like creating and managing models.

The HttpRequestDll is the DLL provided with this building block, which opens a connection, sends the request to the desired endpoint on the Web, Internet or any kind of accessible network and waits for the response to return it. It provides several functions which are available through the C type calling convention.