国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

股票報價的WebService(轉(zhuǎn)天極網(wǎng))之四

2024-07-21 02:21:32
字體:
供稿:網(wǎng)友

創(chuàng)建 web應(yīng)用程序用戶<br>
<br>
下面創(chuàng)建一個web應(yīng)用程序stockconsumer.aspx,它作為這個stockquote(股票報價) web服務(wù)的第一個用戶。 <br>
<br>
  <%@ page language=&quot;c#&quot; %><br>
  <%@ import namespace=&quot;system.xml&quot; %><br>
  <%@ import namespace=&quot;quotes&quot; %><br>
<br>
  以上引入必要的名稱空間。要記住也要引入 quotes名稱空間,它是代理庫的名稱空間。<br>
<br>
  <html><br>
  <head><br>
  <script runat=server><br>
   // wire up the onclick event for a button <br>
   protected void button1_click(object sender, eventargs e)<br>
   {<br>
    file://create a object of the class dailystock (the proxy class)<br>
    dailystock ds = new dailystock();<br>
<br>
    // call the getquote method of the proxy class dailystock and <br>
    // pass the symbol string from the textbox <br>
    string res = ds.getquote(symbol.text);<br>
<br>
    // the returned string has values which are separated <br>
    // by commas.<br>
    // hence we split the returned string into parts <br>
    char[] splitter = {','} ;<br>
    string[] temp = res.split(splitter);<br>
<br>
    // check if the string array returned has more than one <br>
    // elements since if there are less than one elements <br>
    // then an exception must have been returned <br>
    if(temp.length &gt;1)<br>
     {<br>
      // the webservice returns a lot of information about the<br>
      // stock. we only show the relevant portions<br>
      // set the label to current index<br>
      curindex.text = &quot;current index :&quot;+temp[1]; <br>
<br>
      // set the label to current date time<br>
      curdate.text =&quot;last update on&quot;+temp[2]+&quot; at &quot;+temp[3]; <br>
     }<br>
    else<br>
     {<br>
      error.text = &quot;error :&quot;+res ; file://set the error label<br>
     }<br>
    }<br>
   </script><br>
<br>
以上asp.net頁面代碼中,首先對web 服務(wù)dailystock進行例示。由于已經(jīng)生成了代理庫,因此web服務(wù)的調(diào)用方法與其它任何庫的調(diào)用方法都相同。調(diào)用dailystock 類的getquote()方法后,將返回一個字符串,其中包含了以逗號分隔的列表符號的完整信息。<br>
<br>
  我們將限制顯示給客戶的信息為只顯示當前指數(shù)和所報告指數(shù)的日期/時間。為了將字符串分成若干不同的部分,這里使用了字符串類的split方法,在出現(xiàn)逗號的地方將字符串分割成部分。并且,將分割開的字符串組成數(shù)組之后,再使用相關(guān)的數(shù)值為web頁面設(shè)置不同的標簽。 <br>
<br>
  代碼的其余部分<br>
<br>
  <body><br>
  <center><br>
  <h2>.net101 stock quote consumer </h2><br>
<br>
  <form runat=server ><br>
   <table border=1 celspacing=1><br>
    <tr><th>please enter the symbol below</th></tr><br>
    <tr><td><br>
    <asp:textbox id=symbol runat=server /> <br>
    <asp:button id=button1 text=&quot;get quote&quot; onclick=&quot;button1_click&quot; runat=server /><br>
    </td></tr><br>
    <tr><td><asp:label id=curindex runat=server /></td></tr><br>
    <tr><td><asp:label id=curdate runat=server /></td></tr><br>
    <tr><td><asp:label id=error runat=server /></td></tr><br>
   </table><br>
  </form><br>
<br>
  </center><br>
  </body><br>
  </html><br>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 西乌珠穆沁旗| 定陶县| 琼结县| 盈江县| 宿松县| 万全县| 广饶县| 千阳县| 临汾市| 泰和县| 安远县| 泰宁县| 襄垣县| 航空| 西乡县| 英山县| 东阿县| 巴彦县| 彰化市| 江川县| 南宁市| 五台县| 繁昌县| 宜兰市| 宁阳县| 金乡县| 璧山县| 手游| 民丰县| 若尔盖县| 易门县| 汉川市| 藁城市| 孟州市| 绥芬河市| 兴安盟| 邳州市| 同江市| 法库县| 香港| 花垣县|