






















]
C#源文件:testws.asmx
using System;
using System.Data;
using System.IO;
using System.Web;
using System.Web.Services;
namespace dxl_green_web
{
[Serializable]
public class Person
{
public Person()
{
}
public Person(string name,string gender)
{
this.Name=name;
this.Gender=gender;
}
public string Name="";
public string Gender="";
}
[WebService(Namespace="http://www.dxlschool.com/ws/")]
public class test : System.Web.Services.WebService
{
public test()
{
}
[WebMethod]
public string HelloWorld()
{
return "你好";
}
[WebMethod]
public string NowD(){
return DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
}
[WebMethod]
public float[] ALtest(int a){
float[] tint=new float[a];
int i=0;
while (i<a)
{
tint[i]=(float)i;
++i;
}
return tint;
}
[WebMethod]
public string GetPersonTable()
{
DataTable table=new DataTable("Person");
table.Columns.Add("Name");
table.Columns.Add("Gender");
table.Rows.Add(new string[2]{"Alice","Female"});
table.Rows.Add(new string[2]{"Bob","Male"});
table.Rows.Add(new string[2]{"Chris","Female"});
table.Rows.Add(new string[2]{"Dennis","Male"});
table.Rows.Add(new string[2]{"Eric","Male"});
DataSet dataset=new DataSet("PersonTable");
dataset.Tables.Add(table);
System.Text.StringBuilder strbuilder=new System.Text.StringBuilder();
StringWriter writer=new StringWriter(strbuilder);
dataset.WriteXml(writer,System.Data.XmlWriteMode.IgnoreSchema);
return strbuilder.ToString();
}
[WebMethod]
public Person[] GetPersons()
{
Person Alice=new Person("Alice","Female");
Person Bob=new Person("Bob","Male");
Person Chris=new Person("Chris","Female");
Person Dennis=new Person("Dennis","Male");
return new Person[]{Alice,Bob,Chris,Dennis};
}


}
}
posted on 2005-02-24 14:30 HelloSnoopy 阅读(1269) 评论() 收藏 举报
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。