得到“安全通道支持中发生错误”

时间:2018-11-21 01:01:04

标签: javascript wsh

我正在使用https url,我已经使用java完成了相同的任务,但是在那里 已在java.Java中导入证书Java工作正常。但是我的 客户要求是,他要编写Windows Scheduler。该代码 应该可以双击使用。

processSend();

function processSend(attempts) {

    var xmlhttp = new ActiveXObject("MSXML2.ServerXMLHTTP");

    var data = '{"prefixText":"iron","count":5,"contextKey":"Nw,ct,en"}';
    var svcurl = "https://localhost/website/services/itemtablewebsvc.asmx";
    var svcmethod = "GetAutoCompleteItems";

    xmlhttp.open("POST", svcurl + "/" + svcmethod, false);

    xmlhttp.setRequestHeader("Content-Type", "application/json; charset=utf-8");

    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            dataReceived(xmlhttp);
        }
    };

    xmlhttp.setTimeouts(5000, 60000, 10000, 10000);
    try {
        xmlhttp.send(data);
    } catch (err) {
        WScript.Echo("Error:" + err.description + "\n");
        if (!attempts || attempts < 5) {
            WScript.Echo("Retry " + ((attempts || 0) + 1) + "...");
            processSend((attempts || 0) + 1);
        } else {
            WScript.Echo("Too many attemtps.");
        }
    }

}
function dataReceived(xmlhttp) {
    var response;
    if (xmlhttp.responseXML.parseError.errorCode != 0) {
        response = xmlhttp.responseText & " " & xmlhttp.responseXML.parseError.reason;
        WScript.Echo("Response: " + response);
    } else {
        // response = xmlhttp.responseXML.getElementsByTagName("string")(0).childNodes(0).text;
        // response = xmlhttp.responseXML;
        response = xmlhttp.responseText;
        WScript.Echo("Response:\n" + response + "\n");
        var data = eval("(" + xmlhttp.responseText + ")");
        WScript.Echo("Data:");
        for (var i = 0; i < data.d.length; i++) {
            WScript.Echo(i + ":" + eval("(" + data.d[i] + ")").First);
        }
    }
}

0 个答案:

没有答案