WCF VS ASPNET WEB SERVICE

本文探讨了WCF与传统ASMX Web服务的区别。WCF提供了更广泛的适用环境,不仅限于HTTP,还支持TCP/IP等多种协议。文章还讨论了数据序列化方式的不同,包括XML序列化器的局限性和WCF中使用的数据契约属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参看:

1, http://keithelder.net/2008/10/17/WCF-vs-ASMX-WebServices/

2, http://www.cnblogs.com/philzhou/archive/2010/08/11/wcf_vs_web_service.html

3, http://www.bishoylabib.com/2009/08/comparing-asmx-and-wcf.html


要点:

旧的Web Service 仅能在 HTTP 环境下使用,非有比较多的限制条件; 

新的 WCF 几乎不限定使用条件,可在HTTP 及 TCP/IP 等

The development of web service with ASP.NET relies on defining data  and relies on the XmlSerializer to transform data to or from a service.

Key issues with XmlSerializer to serialize .NET types to XML 

  • Only Public fields or Properties of .NET types can be translated into XML.
  • Only the classes which implement IEnumerable interface.
  • Classes that implement the IDictionary interface, such as Hash table can not be serialized.

The WCF uses the DataContractAttribute and DataMemeberAttribute to translate .NET FW types in to XML.

[DataContract] 
public class Item 

    [DataMember] 
    public string ItemID; 
    [DataMember] 
    public decimal ItemQuantity; 
    [DataMember] 
    public decimal ItemPrice;

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值