Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Multiple SOAP request using Javascript problem

    All

    I am using my SOAP API using java script.

    this example explain how to send single soap request using js

    Code:
    var symbol = "MSFT"; 
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.open("POST", "http://www.webservicex.net/stockquote.asmx?op=GetQuote",true);
    xmlhttp.onreadystatechange=function() {
     if (xmlhttp.readyState == 4) {
      alert(xmlhttp.responseText);
      // http://www.terracoder.com convert XML to JSON 
      var json = XMLObjectifier.xmlToJSON(xmlhttp.responseXML);
      var result = json.Body[0].GetQuoteResponse[0].GetQuoteResult[0].Text;
      // Result text is escaped XML string, convert string to XML object then convert to JSON object
      json = XMLObjectifier.xmlToJSON(XMLObjectifier.textToXML(result));
      alert(symbol + ' Stock Quote: $' + json.Stock[0].Last[0].Text); 
     }
    
    
    }
    xmlhttp.setRequestHeader("SOAPAction", "http://www.webserviceX.NET/GetQuote");
    xmlhttp.setRequestHeader("Content-Type", "text/xml");
    var xml = '<?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> ' +
         '<GetQuote xmlns="http://www.webserviceX.NET/"> ' +
           '<symbol>' + symbol + '</symbol> ' +
         '</GetQuote> ' +
       '</soap:Body> ' +
     '</soap:Envelope>';
    xmlhttp.send(xml);
    // ...Include Google and Terracoder JS code here...
    Now i want to send multiple soap request at a time (mean request more than one envelop).

  • #2
    Regular Coder
    Join Date
    Feb 2009
    Location
    NJ, USA
    Posts
    476
    Thanks
    2
    Thanked 70 Times in 69 Posts
    Nothing is stopping you from generating another request the exact same way and running it at the same time. As soon as your code there executes, the request will go out, and you can make more requests immediately because you have set that first one set to be asynchronous (the true argument in your xmlhttp.open() call).

    Just either copy and paste that whole block of code again, or create a reusable function to make your requests.

    -Greg


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •