title: Sending a SOAP request using Javascript
body: <p>I would like to send a SOAP request, using JavaScript, to a web service. I am new to JavaScript. Any help (JavaScript code) would be greatly appreciated. EDIT: The JavaScript will not be run on a website, but on a Parse Cloud Code server. </p>
  
  <p>Here is an example of the SOAP XML (All keys, usernames, passwords, etc. in this XML are for demonstration purposes and do not belong to anyone or any account):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soap.api.controller.web.payjar.com/" xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
    &lt;SOAP-ENV:Header&gt;
     &lt;wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
      &lt;wsse:UsernameToken wsu:Id="UsernameToken-9" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
       &lt;wsse:Username&gt;Staging Integration Store 1&lt;/wsse:Username&gt;
       &lt;wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"&gt;78cXrW1W&lt;/wsse:Password&gt;
      &lt;/wsse:UsernameToken&gt;
     &lt;/wsse:Security&gt;
    &lt;/SOAP-ENV:Header&gt;
    &lt;SOAP-ENV:Body&gt;
     &lt;ns1:doTransaction&gt;
      &lt;Api&gt;ONE_ZERO&lt;/Api&gt;
      &lt;Safekey&gt;{45D5C765-16D2-45A4-8C41-8D6F84042F8C}&lt;/Safekey&gt;
      &lt;TransactionType&gt;FINALIZE&lt;/TransactionType&gt;
      &lt;AdditionalInformation&gt;
       &lt;merchantReference&gt;mercRef_1350047403&lt;/merchantReference&gt;
       &lt;payUReference&gt;11999149347&lt;/payUReference&gt;
      &lt;/AdditionalInformation&gt;
      &lt;Customer&gt;
       &lt;email&gt;
  &lt;/email&gt;
      &lt;firstName&gt;John&lt;/firstName&gt;
      &lt;lastName&gt;Doe&lt;/lastName&gt;
      &lt;merchantUserId&gt;1350047403&lt;/merchantUserId&gt;
      &lt;mobile&gt;
  &lt;/mobile&gt;    
     &lt;/Customer&gt;
     &lt;Basket&gt;
      &lt;amountInCents&gt;6235&lt;/amountInCents&gt;
      &lt;currencyCode&gt;ZAR&lt;/currencyCode&gt;
     &lt;/Basket&gt;
     &lt;Creditcard&gt;
      &lt;amountInCents&gt;6235&lt;/amountInCents&gt;
     &lt;/Creditcard&gt;
    &lt;/ns1:doTransaction&gt;
   &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>