title: SOAP webservice client with javascript
body: <p>I try to write a simple client javascript to access to a SOAP webservice. I found an example on the web </p>
  
  <p><a href="https://thycotic.force.com/support/s/article/Using-Web-Services-with-SOAP-Javascript" rel="nofollow noreferrer">https://thycotic.force.com/support/s/article/Using-Web-Services-with-SOAP-Javascript</a></p>
  
  <p>and </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;head&gt;
      &lt;title&gt;SOAP Javascript Test&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;script type="text/javascript"&gt;
          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 =
                  '&lt;?xml version="1.0" encoding="utf-8"?&gt;' +
                  '&lt;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/"&gt;'; +
                      '&lt;soap:Body&gt;' +
                          '&lt;Authenticate xmlns="urn:https://URL"&gt;' +
                              '&lt;IdTipologiaSegnalazione&gt;7&lt;/IdTipologiaSegnalazione&gt;' +
                              '&lt;IdModalitaSegnalazione&gt;6&lt;/IdModalitaSegnalazione&gt;' +
                              '&lt;IdSegnalante&gt;21856&lt;/IdSegnalante&gt;' +
                              '&lt;Descrizione&gt;test&lt;/Descrizione&gt;' +
                              '&lt;IdTipologiaIntervento&gt;21&lt;/IdTipologiaIntervento&gt;' +
                              '&lt;Matricola&gt;emergenze&lt;/Matricola&gt;' +
                          '&lt;/Authenticate&gt;' +
                      '&lt;/soap:Body&gt;' +
                  '&lt;/soap:Envelope&gt;';
              //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 &amp; send the request when the page loads
          window.onload = function() {
              soap();
          };
  
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  
  </code></pre>
  
  <p>The client seem to works but I do not understand how to send an authorization token given by the server authority. </p>
  
  <p>I try with </p>
  
  <pre><code>xmlhttp.setRequestHeader('Authorization', 'TOKEN');
  </code></pre>
  
  <p>but it do not works</p>