使用WCF而不是ASMX Web服务有什么好处? [英] What are the benefits of using WCF over ASMX web services?

查看:70
本文介绍了使用WCF而不是ASMX Web服务有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

使用WCF而不是ASMX网络服务有什么好处?



请给出使用wcf的好处。 ....



提前致谢。

解决方案

嗨Bapu,



这里有一个简短的评论:



ASMX和WCF之间存在差异,但重要的是要了解WCF支持ASMX提供的相同功能。例如,您可以在WCF服务中使用消息类型,XmlSerialization,自定义SOAP标头和Web服务增强(WSE)。



使用WCF,您可以使用XmlSerializer用于已创建的类型。但是,为了最大化互操作性,建议使用WCF数据协定和DataContractSerializer。 Web服务软件工厂(ASMX)指导包(也称为ASMX指导包)创建的类型如果未添加其他XML序列化属性(如XmlAttributeAttribute),则还应迁移到WCF数据协定。 ASMX指南包中包含一个XmlNamespaceAttribute,用于指定类型的命名空间。



在开发将迁移到WCF的新ASMX服务时,避免使用SOAP扩展,除非您愿意重写它们,或者如果您确信WCF提供了类似的功能。



将服务从ASMX迁移到WCF时,以及ASMX客户端应用程序是否需要访问迁移服务,使用HTTP协议并配置新服务以使用BasicHttpBinding。



如果可能,将客户端应用程序和服务迁移到WCF以利用新安全性WCF提供的功能。在为WCF服务和客户端应用程序配置安全性时,还建议使用WCF安全指南包。

如果迁移的WCF服务必须支持ASMX客户端应用程序,则可以使用与HTTP和HTTPS关联的传输安全性。



WCF提供异常屏蔽,但您应始终为ASMX和WCF服务定义异常处理程序。有关更多信息,请参阅面向服务的应用程序中的异常处理。



控制WCF中维护状态的能力比在ASP.NET中受限制得多。因此,状态管理通常被用作启用ASP.NET兼容模式的主要原因,该模式提供对ASP.NET组件的访问;这意味着您可以更好地控制状态的维护状态。例如,当为ASP.NET兼容性配置服务时,您可以访问提供与ASMX实现相同功能的HTTP上下文类。

开发新的ASMX服务时,应该避免使用在你的服务中的国家;所有服务都应该是无国籍的。



干杯,

Edo


WCF提供吨和吨在传输层机制,绑定等方面对asmx的灵活性。



无法列出所有差异或优势。

一些链接可能只是帮助你掌握基础知识 -

WCF与ASMX Web服务 [ ^ ]

http://msdn.microsoft.com/en-us /library/ff648181.aspx [ ^ ]


http:// www .bishoylabib.com / 2009/08 /比较-ASMX的和wcf.h tml [ ^ ]



http: //keithelder.net/2008/10/17/wcf-vs-asmx-webservices/ [ ^ ]



第二个链接真棒:)

Hello everyone,
What are the benefits of using WCF over ASMX web services?

Please give the benefits of using wcf.....

Thanks in advance.

解决方案

Hi Bapu,

Here''s a brief review:

There are differences between ASMX and WCF, but it is important to also understand that WCF supports the same capabilities that ASMX provides. For example, you can use message types, XmlSerialization, custom SOAP headers, and Web Service Enhancements (WSE) in a WCF service.

Using WCF, you can use the XmlSerializer for types that are already created. However, to maximize interoperability, it is recommended to use WCF data contracts and the DataContractSerializer. The Web Service Software Factory (ASMX) guidance package, also referred to as the ASMX guidance package, creates types that should also migrate to WCF data contracts if no additional XML serialization attributes, such as XmlAttributeAttribute, are added. The ASMX guidance package includes an XmlNamespaceAttribute to specify the namespace of the types.

Avoid the use of SOAP extensions when developing new ASMX services that will be migrated to WCF unless you are willing to rewrite them or if you are confident that WCF provides a similar capability.

When migrating services from ASMX to WCF, and if ASMX client applications need to access the migrated service, use the HTTP protocol and configure the new service to use BasicHttpBinding.

When possible, migrate both client applications and services to WCF to take advantage of the new security features that are available with WCF. Use of the WCF Security guidance package is also recommended when configuring security for WCF services and client applications.
If a migrated WCF service must support ASMX client applications, you can use transport security associated with HTTP and HTTPS.

WCF provides exception shielding, but you should always define exception handlers for both ASMX and WCF services. For more information, see Exception Handling in Service Oriented Applications.

The ability to control where state is maintained in WCF is much more limited than in ASP.NET. As a result, state management is commonly used as the primary reason for enabling the ASP.NET compatibility mode, which provides access to ASP.NET components; this means you have much more control over where state is maintained. For example, when a service is configured for ASP.NET compatibility, you have access to HTTP context classes that provide the same functionality as the ASMX implementation.
When developing new ASMX services, you should avoid the use of state in your services; all services should be stateless.

Cheers,
Edo


WCF provides tons and tons of flexibility over asmx in terms of transport layer mechanisms, bindings etc.

Its impossible to list out all the differences or advantages.
Some links might just help you grasp the basics -
WCF Vs ASMX Web Services[^]
http://msdn.microsoft.com/en-us/library/ff648181.aspx[^]


http://www.bishoylabib.com/2009/08/comparing-asmx-and-wcf.html[^]

http://keithelder.net/2008/10/17/wcf-vs-asmx-webservices/[^]

Second link is awesome :)


这篇关于使用WCF而不是ASMX Web服务有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆