Provides support for the HTTP protocol for WWW-based user interfaces.
License:
GPL
Introduction
Module of the transport protocol HTTP is designed to support the implementation of network protocol HTTP (Hypertext Transfer Protocol) in the system OpenSCADA.
HTTP Protocol is used to transfer the WWW contents. For example, via HTTP the following types of documents are transmitted: html, xhtml, png, java, and many others. Adding the HTTP support in OpenSCADA system together with the Sockets transport allows to implement various user functions based on the WWW interface. The module implements two main methods of the HTTP protocol: "GET" and "POST". "HTTP" module provides control of the integrity of HTTP-queries and, jointly with "Sockets" transport, allows to "collect" holistic requests of their fragments, as well as maintain the keeping of the connection alive (Keep-Alive).
For flexible connection of the user interfaces to the module the modular mechanism within the module HTTP is used. In the role of modules the modules of subsystem the "User interfaces" are used with the additional information field "SubType" with the value of "WWW".
In the requests for the Web resources the URL(Universal Resource Locator) are commonly used, hence the URL is passed as the main parameter via HTTP. The first element of the requested URL is used to identify the module UI. For example URL: http://localhost:10002/WebCfg means — address to module WebCfg on the host http://localhost:10002. In the case of an incorrect indication of the module ID, or when you address without identifier of the module at all, HTTP module generates the dialogue of the information on the input and with the choice of one of the available user interfaces. Example of a dialogue is shown in Figure 1.
Fig.1. Dialog of the choice of WWW-interface module.
1. Authentication
Module supports authentication in the system OpenSCADA while providing access to the WEB-interface modules (Fig.2). Dialogue is formed in the language of XHTML 1.0 Transitional!
Fig.2. Authentication dialogue in the system OpenSCADA.
For ease of Web-based interface module provides the ability to automatically log on behalf of the specified user. Configuring automatic login to make by the module settings page (Fig.3).
Fig.3. The module configuring page.
On the module settings you can specify the lifetime of the authentication, HTML-template of custom interface and set up automatic login.
Automatic login is carried out by matching the address indicated in the column "Address", on behalf of the user specified in the column "User".
In the HTML-template must specify the address of the file HTML/XHTML, which will be used for the formation of internal interfaces. For example, to select the modules and the login page. From the template required correct XHTML, allowing parse the file by XML-parser, and the presence of tags "#####CONTEXT#####" at the location of the dynamic content. Resource template files, represented by images, CSS and JavaScript files are searched from the directory in which the specified file location template. If errors are found in the template will be used in a standard interface.
2. The modules of user WEB-interface
Modules of the user interface (UI) designed to work with HTTP module, should indicate an information field "SubType" with the value "WWW" and "Auth" field with the value "1" if the module requires an authentication at login. For communication of HTTP module and UI modules an advanced communication mechanism is used. This mechanism involves the export of interface functions. In this case the UI modules must export the following function:
void HttpGet( const string &url, string &page, const string &sender, vector<string> &vars, const string &user ); — GET method with the parameters:
url — address of the request; page — page with the answer; sender — address of the sender; vars — request variables; user — user of the system.
void HttpPost( const string &url, string &page, const string &sender, vector<string> &vars, const string &user ); — POST method with the parameters:
url — address of the request; page — page with the answer and with the contents of the body of the POST request; sender — address of the sender; vars — request variables; user — user of the system.
Then, in the case of a HTTP GET request, the function HttpGet will be called, and in the case of the POST request, the function HttpPost will be called in the appropriate UI module.
3. Outgoing requests function's API
The outgoing function of API operate by HTTP-request's content which wrapped to XML-packages. The request structure is:
req — request method, supported methods "GET" and "POST".
host — http-server address into format [HostAddr]:[HostIp]. If that field have been passed then used node address which set into address field of the transport.
uri — resource address, file or direcory, at http-server.
pId, pVal — identifier and value of addition http-parameters. You can set multiply http-parameters by different prm tags set.
cName, cFileName, cVal — name, file-name and value of content-element of POST-request. You can set multiply content-elements by different cnt tags set.
cpId, cpVal — identifier and value of addition content-parameters. You can set multiply content-parameters by different prm tags set;