Delayed Stock Quote Example at XMethods

Discussion in 'Javascript' started by gimme_this_gimme_that@yahoo.com, Jun 18, 2007.

  1. Guest

    Does anyone have a JavaScript SOAP stock price function?

    I've discovered something here:

    Visit: http://services.xmethods.net/

    And for the WSDL:

    Scroll all the way to the bottom of the page and click on Delayed
    Stock Quote

    This might be helpful:
    SOAP_Endpoint_URL : "http://services.xmethods.net:80/soap"

    I don't need something which parses the result, I can handle that,
    just something that fetches the price associated with any signal.


    I tried this wild shot. But I have a hunch I should try CallSOAP
    instead of using MSXML:

    I'm posting this to show I've made a good faith stab in the dark at
    finding a solution on my own. This probably isn't a good template to
    use for starters ...


    <html>
    <head>
    <script language="JavaScript">
    var objHttp;
    var objXmlDoc;


    function getDataFromWS(methodName, dataSetName, wsParamValue,
    wsParamName, szUrl)
    {

    // create the XML object
    objXmlDoc = new ActiveXObject("Msxml2.DOMDocument");

    if (objXmlDoc == null)
    {
    alert("Unable to create DOM document!");

    } else {

    // create an XmlHttp instance
    objHttp = new ActiveXObject("Microsoft.XMLHTTP");

    strEnvelope = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://
    schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/
    1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema
    \">\n" +
    "<SOAP-ENV:Body>\n" +
    "<ns1:getQuote xmlns:ns1=\"urn:xmethods-delayed-quotes\" SOAP-
    ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n" +
    "<symbol xsi:type=\"xsd:string\">IBM</symbol>\n" +
    "</ns1:getQuote>\n" +
    "</SOAP-ENV:Body>\n" +
    "</SOAP-ENV:Envelope>";
    alert(strEnvelope);

    // Set up the post
    objHttp.onreadystatechange = function(){
    // a readyState of 4 means we're ready to use the data
    returned by XMLHTTP
    if (objHttp.readyState == 4)
    {
    // get the return envelope
    var szResponse = objHttp.responseText;
    alert("SZ " + szResponse);
    // load the return into an XML data island
    objXmlDoc.loadXML(szResponse);
    if (objXmlDoc.parseError.errorCode != 0) {
    var xmlErr = objXmlDoc.parseError;
    alert("You have error " + xmlErr.reason);
    } else {
    alert(dataSetName);
    }

    }
    }

    szUrl = szUrl + methodName;

    if (wsParamValue != null)
    {
    szUrl += "?" + wsParamName + "=" + wsParamValue;
    }

    // send the POST to the Web service
    szUrl = "http://64.124.140.30:9090/soap";
    szUrl = "http://services.xmethods.net:80/soap";
    objHttp.open("POST", szUrl, true);
    objHttp.setRequestHeader("Content-Type", "application/x-www-form-
    urlencoded");
    objHttp.send(strEnvelope);
    }
    }
    var methodName="getQuote";
    var dataSetName = "";
    var wsParamName ="Symbol";
    var wsParamValue = "AAPL";
    var szUrl = "http://services.xmethods.net:80/soap/";
    getDataFromWS(methodName, dataSetName, wsParamValue, wsParamName,
    szUrl);
    alert("DS" + dataSetName);
    </script>
    </head>
    <body>
    hello world
    </body>
    </html>
     
    , Jun 18, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. savvy
    Replies:
    1
    Views:
    513
    Cowboy \(Gregory A. Beamer\)
    Jun 28, 2006
  2. parvathi
    Replies:
    0
    Views:
    453
    parvathi
    Feb 3, 2009
  3. Joydeep
    Replies:
    1
    Views:
    199
  4. matt
    Replies:
    1
    Views:
    421
  5. matt
    Replies:
    8
    Views:
    241
    Mauricio Fernández
    Jun 19, 2004
Loading...

Share This Page