title: Calling Web Service using Javascript with a SOAP envelope fails
body: <p>I try to access from a browser a simple mailing list service I developed. I adapted a working example I found but I don't know why the request doesn't seem to reach the service and so no response is returned. </p>
  
  <p>Using a SOAP envelope is a requirement, I need to know what is possibly wrong with this code, not how I could do the same thing using other techniques. (The service is deployed correctly on a GlassFish server and I have a working Java client to test it, so no problem with the service) </p>
  
  <p>Does anyone see something bad (I'm joining the WSDL too, if you need any other detail don't hesitate)? Thanks!</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Soap Invocation&lt;/title&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  
      &lt;script type="text/javascript"&gt;
  
          var request = null;
  
          function createRequest() {
              if (window.XMLHttpRequest){
                  request=new XMLHttpRequest();
              }
              else{
                  if (new ActiveXObject("Microsoft.XMLHTTP")) {
                      request = new ActiveXObject("Microsoft.XMLHTTP");
                  } else {
                      request = new ActiveXObject("Msxml2.XMLHTTP");
                  }
              } 
          }
  
          function getMail() {
              createRequest();
              var envelope = "&lt;?xml version='1.0' encoding='UTF-8'?&gt;";
              envelope += "&lt;soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'&gt;";
              envelope += "&lt;soap:Header/&gt;";
              envelope += "&lt;soap:Body&gt;";
              envelope += "&lt;ns2:getMails xmlns:ns2='http://service.inf4375.com/'&gt;";
              envelope += "&lt;/ns2:getMails&gt;";
              envelope += "&lt;/soap:Body&gt;";
              envelope += "&lt;/soap:Envelope&gt;";
  
              var url = "http://127.0.0.1:8080/SoapService/MailingService";
  
              request.onreadystatechange = updatePage;
  
              request.open("GET", url, false);
              request.setRequestHeader("Content-Type", "text/html");
              request.setRequestHeader("SOAPAction", "");
              request.send(envelope);
          }
  
          function updatePage() {
  
              if(request.readyState == 4) {
                  document.getElementById("get").innerHTML = "&lt;p&gt;" + request.responseXML.selectSingleNode("//return").text + "&lt;/p&gt;";
              } else {
                  document.getElementById("get").innerHTML = "Loading..."
              }
  
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;input type="button" value="GetMail" onclick="getMail();" /&gt;
      &lt;span id="get"&gt;&lt;/span&gt;       
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The WSDL :</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
  &lt;definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.inf4375.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://service.inf4375.com/" name="MailingService"&gt;
  &lt;types&gt;
      &lt;xsd:schema&gt;
          &lt;xsd:import namespace="http://service.inf4375.com/" schemaLocation="http://localhost:8080/SoapService/MailingService?xsd=1"/&gt;
      &lt;/xsd:schema&gt;
  &lt;/types&gt;
  &lt;message name="getMails"&gt;
      &lt;part name="parameters" element="tns:getMails"/&gt;
  &lt;/message&gt;
  &lt;message name="getMailsResponse"&gt;
      &lt;part name="parameters" element="tns:getMailsResponse"/&gt;
  &lt;/message&gt;
  &lt;message name="addMail"&gt;
      &lt;part name="parameters" element="tns:addMail"/&gt;
  &lt;/message&gt;
  &lt;message name="addMailResponse"&gt;
      &lt;part name="parameters" element="tns:addMailResponse"/&gt;
  &lt;/message&gt;
  &lt;portType name="Mailing"&gt;
      &lt;operation name="getMails"&gt;
          &lt;input wsam:Action="http://service.inf4375.com/Mailing/getMailsRequest" message="tns:getMails"/&gt;
          &lt;output wsam:Action="http://service.inf4375.com/Mailing/getMailsResponse" message="tns:getMailsResponse"/&gt;
      &lt;/operation&gt;
      &lt;operation name="addMail"&gt;
          &lt;input wsam:Action="http://service.inf4375.com/Mailing/addMailRequest" message="tns:addMail"/&gt;
          &lt;output wsam:Action="http://service.inf4375.com/Mailing/addMailResponse" message="tns:addMailResponse"/&gt;
      &lt;/operation&gt;
  &lt;/portType&gt;
  &lt;binding name="MailingPortBinding" type="tns:Mailing"&gt;
      &lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/&gt;
      &lt;operation name="getMails"&gt;
          &lt;soap:operation soapAction=""/&gt;
          &lt;input&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/input&gt;
          &lt;output&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/output&gt;
      &lt;/operation&gt;
      &lt;operation name="addMail"&gt;
          &lt;soap:operation soapAction=""/&gt;
          &lt;input&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/input&gt;
          &lt;output&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/output&gt;
      &lt;/operation&gt;
  &lt;/binding&gt;
  &lt;service name="MailingService"&gt;
      &lt;port name="MailingPort" binding="tns:MailingPortBinding"&gt;
          &lt;soap:address location="http://localhost:8080/SoapService/MailingService"/&gt;
      &lt;/port&gt;
  &lt;/service&gt;
  </code></pre>
  
  <p></p>
  
  <p>I don't get any errors in the Error Console when I'm trying to execute it on Firefox, and Internet Explorer is only displaying the <code>Loading...</code> and nothing more.</p>