SOAP Stock Examples

Your Name:

Add Symbol:

 Holdings (qty):



Quotes provided by Yahoo                        > Graph Stock Performance

Powered by Web ConnectionCreated by Rick Strahl | [Web Connection Enterprise page]
[Show SOAP Client - Web Code] | [Show SOAP Web Service]

How the Stock Portfolio works:
This example demonstrates Server to Server communication using SOAP as the mechanism to retrieve remote information - in this case stock quotes in the form of an object that contains the quote data. When you hit Refresh on this page the Web Server is accessed and the current portfolio's symbols are gathered into an XML string. This string is then passed as a parameter to the SOAP Web Service that provides the stock quote functionality. The GetStockQuotes Web Service method then goes out and internally calls the GetStockQuote method which returns a single object repeatedly until all quotes have been retrieved. In this case the SOAP Web Service also runs on the West Wind site, but it could potentially run elsewhere. The actual quotes are retrieved from yet another server on the NASDAQ site also served in XML format.

The resulting quotes are then turned into an XML string and returned as part of the SOAP call via return parameter to the client application (this Web page's server code). The code takes the result XML parameter and re-creates the indivdual quote objects and updates the portfolio with this data. The app then displays and recalculates the entire portfolio here. You can take a look at the server side code that performs the SOAP client call and the Web Service on the SOAP server that makes the calls to the NASDAQ site.

How the single stock quote works:
This example uses JScript code to call the same SOAP Web Service to retrieve a single stock quote using the GetStockQuote() method. The method returns an Object parameter, which is returned to the JScript code as an XML string. The XML is loaded into the XMLDOM and then uses selectSingleNode() to retrieve the values to display from the object. An HTML string is built and substituted directly into this document below the quote textbox.

You can view source to see the GetStockQuote() function in this page, and look at wwsoap.js, which is a very basic SOAP client.