带javascript的SOAP Web服务客户端

带javascript的SOAP Web服务客户端,javascript,soap,authorization,token,webservice-client,Javascript,Soap,Authorization,Token,Webservice Client,我尝试编写一个简单的客户端javascript来访问SOAP Web服务。我在网上找到了一个例子 及 但是它不起作用您正在发送带有字符串令牌的授权头。您需要发送实际的令牌。我不会在问题中写入令牌,只是因为令牌是供我公司私人使用的,但在网页中,我在单个用户之间使用了正确的令牌 <!DOCTYPE html> <head> <title>SOAP Javascript Test</title> </head> <body&g

我尝试编写一个简单的客户端javascript来访问SOAP Web服务。我在网上找到了一个例子


但是它不起作用

您正在发送带有字符串
令牌的
授权
头。您需要发送实际的令牌。我不会在问题中写入令牌,只是因为令牌是供我公司私人使用的,但在网页中,我在单个用户之间使用了正确的令牌
<!DOCTYPE html>
<head>
    <title>SOAP Javascript Test</title>
</head>
<body>
    <script type="text/javascript">
        function soap() {
            var xmlhttp = new XMLHttpRequest();

            //replace second argument with the path to your Secret Server webservices
            xmlhttp.open('POST', 'https://URL//MANU_WSManutenzioni_MOGE/', true);

            //create the SOAP request
            //replace username, password (and org + domain, if necessary) with the appropriate info
            var strRequest =
                '<?xml version="1.0" encoding="utf-8"?>' +
                '<soap:Envelope ' +
                    'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"" ' +
                    'xmlns:xsd="http://www.w3.org/2001/XMLSchema"" ' +
                    'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'; +
                    '<soap:Body>' +
                        '<Authenticate xmlns="urn:https://URL">' +
                            '<IdTipologiaSegnalazione>7</IdTipologiaSegnalazione>' +
                            '<IdModalitaSegnalazione>6</IdModalitaSegnalazione>' +
                            '<IdSegnalante>21856</IdSegnalante>' +
                            '<Descrizione>test</Descrizione>' +
                            '<IdTipologiaIntervento>21</IdTipologiaIntervento>' +
                            '<Matricola>emergenze</Matricola>' +
                        '</Authenticate>' +
                    '</soap:Body>' +
                '</soap:Envelope>';
            //specify request headers
            //xmlhttp.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
            xmlhttp.setRequestHeader('Authorization', 'TOKEN');

            //FOR TESTING: display results in an alert box once the response is received
            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4) {
                    alert(xmlhttp.responseText);
                }
            };

            //send the SOAP request
            xmlhttp.send(strRequest);
        };

        //build & send the request when the page loads
        window.onload = function() {
            soap();
        };

    </script>
</body>
</html>


xmlhttp.setRequestHeader('Authorization', 'TOKEN');