事件中、インターネット上でWebベースの金融システムを見ました。 Activexを介して実装されています。実際、WebServiceを使用してDHTMLを組み合わせると、ActiveXを完全に脇に置くことができます。これが簡単な例です。
まず第一に、非常に簡単なWebサービスは詳細に説明しません。コメントを見てください。
ファイルStudy.asmx.cs
システムの使用。
System.Collectionsを使用します。
System.comPonentModelを使用しています。
System.Dataを使用しています。
System.Dianosticsを使用します。
system.webを使用しています。
System.Web.Servicesを使用しています。
System.xml.Serializationを使用します。
名前空間StudyXml
{
/// <summary>
/// <br> Webサービスの例</br>
/// <br>著者:[電子メール保護] </br>
/// <br>日付:2001/12/21 </br>
/// <br>歴史:2001年に完了// 12/21 </br>
/// </summary>
/// <Remarks>
///このWebサイトで実装されている機能は非常に簡単です
/// 2つの主な機能があります。1つは事前定義されたアイテム配列を取得することです。
///別のものは、レコードタイプのレコードを保存することです
/// </remarks>
パブリッククラスの調査:System.Web.Services.Webservice
{
Private ArrayList M_Arrites;
Private ArrayList M_ARRREOCRDS;
パブリックスタディ()
{
// CodeGen:この呼び出しは、ASP.NET Webサービスデザイナーによって必要です
initializeComponent();
this.m_arrecords = new arrayList();
this.m_arrites = new ArrayList();
//いくつかの実験データを追加します
for(int i = 0; i <100; i ++)
{
this.m_arrites.add(new item(itemname + i.tostring()
、itemvalue +(i + 1).toString()));
}
}
/// <summary>
///
/// </summary>
/// <param name = a_stritemname> item name </param>
/// <turnss>アイテムオブジェクト</returns>
プライベートアイテムgetItem(string a_stritemname)
{
// throw(new Exception(server.urldecode(a_stritemname))));
for(int i = 0; i <this.m_arrites.count; i ++)
{
item item =(item)this.m_arrites [i];
if(item.name == server.urldecode(a_stritemname).trim()))
{
返品アイテム。
}
}
nullを返します。
}
#regionコンポーネントデザイナー生成コード
// Webサービスデザイナーが必要とします
プライベートicontainerコンポーネント= null;
/// <summary>
///デザイナーサポートに必要な方法 - 変更しないでください
///コードエディターを使用したこのメソッドの内容。
/// </summary>
private void initializeComponent()
{
}
/// <summary>
///使用されているリソースをクリーンアップします。
/// </summary>
保護されたオーバーライドボイド処分(bool disinging)
{
if(disping && components!= null)
{
components.dispose();
}
base.dispose(処分);
}
#endregion
[WebMethod]
public void additem(string a_strname、string a_strvalue)
{
this.m_arrites.add(new item(a_strname、a_strvalue));
}
/// <summary>
///アイテムリストを取得します
/// </summary>
/// <Returns> arrayList </returns>
[WebMethod]
[xmlinclude(typeof(item))]
public arrayList getItems()
{
this.m_arritesを返します。
}
/// <summary>
///レコードを保存します
/// </summary>
/// <param name = a_stritemname> </param>
/// <param name = a_strdemoname> </param>
/// <param name = a_intdemoamount> </param>
/// <返品>成功した場合は、falseを返します</returns>
[WebMethod]
Public Bool Saverecord(String a_stritemname
、string a_strdemoname、int a_intdemoamount)
{
試す
{
item item = this.getitem(a_stritemname);
if(item!= null)
{
this.m_arreocrds.add(new Record(this.m_arrreocrds.count + 1
、 アイテム
、新しいデモ(a_strdemoname、a_intdemoamount))));
}
それ以外
{
スロー(新しい例外(アイテムを指定するための名前エラー!));
}
trueを返します。
}
キャッチ(例外e)
{
Thro(new Exception(e.toString())));
// falseを返します。
}
} //終了メソッド
} // end class
/// <summary>
/// selectのようなオプションに対応する簡単なクラス
/// </summary>
パブリッククラスアイテム
{
プライベート文字列m_strname;
プライベート文字列m_strvalue;
パブリック文字列名
{
得る
{
this.m_strnameを返します。
}
セット
{
this.m_strname = value;
}
}
パブリック文字列値
{
得る
{
this.m_strvalueを返します。
}
セット
{
this.m_strvalue = value;
}
}
パブリックアイテム(文字列a_strname、string a_strvalue)
{
this.m_strname = a_strname;
this.m_strvalue = a_strvalue;
}
public item()
{
this.m_strname =;
this.m_strvalue =;
}
} // end class
/// <summary>
///簡単な例クラス
///構造は非常にシンプルで、3つのメンバー変数です
///多数のタイプint、
///アイテムタイプ、デモタイプ
/// </summary>
パブリッククラスの記録
{
Private int m_intid;
プライベートアイテムM_OBJMYITEM;
プライベートデモM_OBJMYDEMO;
パブリックレコード()
{
this.m_intid = 0;
this.m_objmydemo = new demo();
this.m_objmyitem = new item();
}
パブリックレコード(int a_intid、item a_objitem、demo a_objdemo)
{
this.m_intid = a_intid;
this.m_objmydemo = a_objdemo;
this.m_objmyitem = a_objitem;
}
} // calを終了します
/// <summary>
///単純な例クラス
///構造は非常にシンプルで、2つのメンバー変数、1つの名前と1つの量のみがあります
/// </summary>
パブリッククラスのデモ
{
プライベート文字列m_strname;
Private int m_intamount;
パブリック文字列名
{
得る
{
this.m_strnameを返します。
}
セット
{
this.m_strname = value;
}
}
公開額
{
得る
{
this.m_intamount;
}
セット
{
this.m_intamount = value;
}
}
/// <summary>
///コンストラクター
/// </summary>
public demo()
{
this.m_intamount = 0;
this.m_strname =;
}
/// <summary>
///オーバーロードコンストラクター
/// </summary>
/// <param name = a_strname> </param>
/// <param name = a_intamount> </param>
パブリックデモ(String a_strname、int a_intamount)
{
this.m_intamount = a_intamount;
this.m_strname = a_strname;
}
} // end class
} //名前空間を終了します