You??™ll
see this in the next section.
Creating the Wrapper Web Service
This web service provides a web method that makes a call to the Yahoo! iFinance server
on your behalf, takes the CSV that is returned from it, and serializes it as a DataTable. It is
designed to be consumed by a .NET-based client, so using a DataTable object works
nicely. If you want to expose a web service that is easily interoperable with other platforms,
you should serialize the returned data using straight XML that can be parsed on
the client side. To do that, we have a web method called GetFullPriceHistory, which takes
in a stock ticker and an integer value representing the number of days. Here is the code
for this web method:
[WebMethod]
public DataTable GetFullPriceHistory(string strTicker, int nDays)
{
WebClient client = new WebClient();
StringBuilder strURI = new
StringBuilder("http://ichart.finance.yahoo.com/table.csv?s=");
strURI.Append(strTicker);
strURI.Append("&d=1&e=22&f=2007&g=d&a=8&b=28&c=1997&ignore=.csv");
Stream data = client.OpenRead(strURI.ToString());
StreamReader reader = new StreamReader(data);
string s = reader.
Pages:
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334