Promotic

HttpRequest examples for the open("GET") method

This type of the communication may be quite time consuming, depending on the volume of transmitted data connectivity performance. Such delays may have negative impact on the application itself. Therefore it is recommended to call the communication from a properly configured PmaSequencer object.
 
Getting the XML object:
The example shows how to obtain the oXML object. The parsing of such object is not included in this example.
JavaScriptSelect and copy to clipboard

var sUrl = "https://www.promotic.eu/test/data/exam.xml";
var oReq = Pm.AxGetObject("new", "MSXML2.ServerXMLHTTP.6.0");

oReq.open("GET", sUrl, false);
oReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
oReq.onreadystatechange = HandleStateChange;
oReq.send();

function HandleStateChange()
{
if (oReq.readyState == 4)
{
Pm.MessageBox("Text", oReq.responseText, 0x0);
var oXML = oReq.responseXML;
}
}
oReq.abort();

Getting the text from a secured server by communication with personal certificate.:
The personal certificate must be properly registered on the client computer. Its registered name is used by the setOption method for server authentization. The row in comment also provides the option to ignore the certificate authentication request from the server. This can be handy if the certificate is no longer valid or if the authentication is not required by the server.
JavaScriptSelect and copy to clipboard

var oReq, sUrl, sCert;
var sCert = "My personal certificate";
var sUrl = "https://www.promotic.eu/test/data/getewon.txt";
var oReq = Pm.AxGetObject("new", "MSXML2.ServerXMLHTTP.6.0");

oReq.open("GET", sUrl, false);
oReq.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
oReq.setOption(3, sCert);
// oReq.setOption(2, oReq.getOption(2));
oReq.onreadystatechange = HandleStateChange;
oReq.send();

function HandleStateChange()
{
if (oReq.readyState == 4)
{
Pm.MessageBox("Text", oReq.responseText, 0x0);
}
}
PROMOTIC 9.0.18 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.