title: I was having an Internal server error 500 on sending a SOAP request
body: <p>I am getting this error "POST :
  <a href="http://www.thomas-bayer.com/axis2/services/BLZService?wsdl" rel="nofollow noreferrer">http://www.thomas-bayer.com/axis2/services/BLZService?wsdl</a> 
  500 (Internal Server Error)" on attempting to send a SOAP request using Java script and HTML5. I'm seeing this error in the console of chrome.I already installed CORS plugin(to remove the Allow-control-Allow-origin error) and added lines of code to remove the CORS problem.</p>
  
  <p>This WSDL is working fine in soap UI and giving correct response.</p>
  
  <p><a href="https://i.stack.imgur.com/JNshu.png" rel="nofollow noreferrer">screenshot of the error,click here</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  
      &lt;script &gt;
          function soapReq()
    {
    
    console.log("Hi");
    var str = '&lt;soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-  envelope" xmlns:blz="http://thomas-bayer.com/blz/"&gt;' 
     '&lt;soap:Header&gt;' +
       ' &lt;httpProtocol&gt; ' +
          '&lt;customHeaders&gt;' +
            '&lt;add name="Access-Control-Allow-Origin" value="True" /&gt;' +
            '&lt;add name="Access-Control-Allow-Headers" value="Content-Type" /&gt;' +
            '&lt;add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /&gt;' +
            ' &lt;/customHeaders&gt;' +
        '&lt;/httpProtocol&gt;' + 
   '&lt;/soap:Header&gt;' +
     '&lt;soap:Body&gt;' +
        '&lt;blz:getBank&gt;' +
           '&lt;blz:blz&gt;66452776&lt;/blz:blz&gt;' +
        '&lt;/blz:getBank&gt;' +
      
     '&lt;/soap:Body&gt;' +
  '&lt;/soap:Envelope&gt;' ;
  
          function createCORSRequest(method, url) {
    
    
    var xhr = new XMLHttpRequest();
    if ("withCredentials" in xhr) {
      
      xhr.open(method, url, true);
   
    } else if (typeof XDomainRequest != "undefined") {
      
      xhr = new XDomainRequest();
      xhr.open(method, url);
    } else {
     
      xhr = null;
    }
    return xhr;
  }
  
  // Helper method to parse the title tag from the response.
  function getTitle(text) {
    return text.match('&lt;title&gt;(.*)?&lt;/title&gt;');
  }
  
  // Make the actual CORS request.
  
    var url = 'http://www.thomas-bayer.com/axis2/services/BLZService';
  
    var xhr = createCORSRequest('POST', url);
    if (!xhr) {
      alert('CORS not supported');
      return;
    }
  
    // Response handlers.
    xhr.onload = function() {
      var text = xhr.responseText;
      var title = getTitle(text);
      alert('Response from CORS request to ' + url + ': ' + title);
   console.log(text);
    };
  
    xhr.onerror = function() {
      alert('Woops, there was an error making the request.');
    };
   xhr.setRequestHeader('Content-Type', 'text/xml');
    xhr.send(str);
  
  }
  
  
   
             
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
   &lt;form&gt;
      &lt;input type="button" value="SOAP Request" onclick="soapReq();" /&gt;
   &lt;/form&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>&lt;add name="Access-Control-Allow-Origin" value="*" /&gt;
        &lt;add name="Access-Control-Allow-Headers" value="Content-Type" /&gt;
        &lt;add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /&gt;
     &lt;/customHeaders&gt;
  &lt;/httpProtocol&gt;
   &lt;form&gt;
      &lt;input type="button" value="SOAP Request" onclick="soapReq();" /&gt;
   &lt;/form&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>