• λ我爱Aspx >> C#.Net >> 股票报价的WebService之四
  • 股票报价的WebService之四

  • :aspxer  Դ:internet  :2007-5-12 7:53:18  ؼ:web,webservice
  • 创建 Web应用程序用户

    下面创建一个Web应用程序StockConsumer.ASPx,它作为这个StockQuote(股票报价) Web服务的第一个用户。

    <%@ Page language="C#" %>

    <%@ Import Namespace="System.XML" %>

    <%@ Import Namespace="Quotes" %>

    以上引入必要的名称空间。要记住也要引入 Quotes名称空间,它是代理库的名称空间。

    <html>

    <head>

    <script runat=server>

    // Wire up the onClick event for a button

    protected void button1_Click(object sender, EventArgs e)

    {

    file://Create a object of the class DailyStock (the proxy class)

    DailyStock ds = new DailyStock();

    // Call the GetQuote method of the proxy class DailyStock and

    // pass the symbol string from the textbox

    string res = ds.GetQuote(symbol.Text);

    // The returned string has values which are separated

    // by commas.

    // Hence we split the returned string into parts

    char[] splitter = {','} ;

    string[] temp = res.Split(splitter);

    // Check if the string array returned has more than one

    // elements since if there are less than one elements

    // then an exception must have been returned

    if(temp.Length >1)

    {

    // The WebService returns a lot of information about the

    // stock. We only show the relevant portions

    // Set the label to current Index

    curindex.Text = "Current Index :"+temp[1];

    // Set the label to current Date Time

    curdate.Text ="Last Update on"+temp[2]+" at "+temp[3];

    Ҷƪл˵?
  • һƪ用ASP做一个域名查询系统
    һƪ用ASP+XML打造留言本 - 1