Promotic

HttpRequest examples for the open("POST") 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.
 
Sending the XML text string to the server:
The example string to be sent is created in the sXML variable.
JavaScriptSelect and copy to clipboard

var sXML = '<?xml version=\"1.0\" encoding=\"utf-8\"?><pm><data><item><name ID=\"B\">d0</name><value>9.381083</value></item><item><name ID=\"P\">d1</name><value>20.34651</value></item></data></pm>';
var sUrl = "https://servername/UploadData/exam.xml";
var oReq = Pm.AxGetObject("new", "MSXML2.ServerXMLHTTP.6.0");

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

function HandleStateChange()
{
if (oReq.readyState == 4)
{
Pm.Debug("HttpRequest Send file = OK");
}
}

Sending the text to 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 the 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 sTxt = "Text to server";
var sCert = "My personal certificate";
var sUrl = "https://servername/UploadData/document.txt";
var oReq = Pm.AxGetObject("new", "MSXML2.ServerXMLHTTP.6.0");

oReq.open("POST", 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(sTxt);

function HandleStateChange()
{
if (oReq.readyState == 4)
{
Pm.Debug("HttpRequest Send file = OK");
}
}
oReq.abort();
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

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