Delayed Stock Quote Example at XMethods

  • Thread starter gimme_this_gimme_that
  • Start date
G

gimme_this_gimme_that

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top