惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - HelloSnoopy

写了个用一个文件定义样式的DataGrid [转载]如何奔向程序员打工的出头之日? 一定要讲给孩子们的20个小故事 人脉对职业生涯最重要 (转) 爱情的10种样子,送给懂爱的朋友们 装了Enterprise Library.NET 200501release C#判断是否为数字的最好速度! 开源的 BugTracker.net 错误跟踪管理系统 Enjoy new year of 2005! Flash AS2 用EventDispatcher广播事件 设计模式随笔-让众口不再难调 CodeSmith使用心得 [专题]MVC构架模式 使用Microsoft Application Block之Cache Application 用一条SQL完成数据表的行统计 如何使IFrame的长宽与内容自动适应大小 为Project提供一个统一风格的DataGrid 用于读取树形任一节点下所有级别子节点的SqlServer UDF asp.net forums中定时器的应用
一个最基本的WebService+Flash调用的实例
HelloSnoopy · 2005-02-24 · via 博客园 - HelloSnoopy
一个最基本的WebService+Flash调用的实例
[前几天的一则笔记,随手写的,没有注释。
自己的体会:对于Flash+asp.net的开发,用ws比直接使用flash+xml+asp.net要更快捷一些,而且层次分明,可以让UI设计和后台完全隔离。
对于大数据集的处理,倾向于在服务端撰写相关类,序列化之后输出,这样在客户端处理更快捷,而且适应性更强。
最后一个感受:直接使用WebServiceAPI比使用WebServiceConnector组件更加灵活,直接。

]

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};
}




}

}


AS2源文件

Note:
1、 在多种语言共存的编程环境下,是不适合使用类似DataSet这种只属于特定语言的数据类型的。应该尽量使用简单数据类型以及简单数据类型的数组。
2、 应当很谨慎的决定是否需要通过Web Service来返回大量数据。由于网络传输的开销既包括HTTP连接建立的时间,也包括传送数据的时间,因此需要在减少访问服务器次数和减少网络传输量之间寻找一个合适的平衡。如非必须,则不适合通过Web Service传送含有几十条或者几百条数据的数据表。
3、 使用序列化可以让数据在客户端更容易处理。

posted on 2005-02-24 14:30  HelloSnoopy  阅读(1269)  评论()    收藏  举报