简体   繁体   English

Visual Studio选项有什么区别:ASP.NET Web服务和WCF服务

[英]What is the difference between the Visual Studio Options: ASP.NET Web Service and WCF Service

I see that there are two options that I know can be used in web services... WCF obviously, and ASP.NET Web Services. 我看到有两个选项,我知道可以在Web服务中使用...显然,WCF和ASP.NET Web服务。 What's the difference? 有什么不同? I just started picking up WCF recently and had a little exposure to web services in the past, but I'm certainly not an expert. 我刚刚开始接收WCF并且过去曾接触过一些Web服务,但我当然不是专家。

it is quite easy to know the differences. 知道这些差异很容易。

ASP.NET Web Method is called ASMX [because of the file extension] (check 4GuysFromRolla about this, they have a good tutorial ) ASP.NET Web方法被称为ASMX [因为文件扩展名](关于这个,检查4GuysFromRolla,他们有一个很好的教程

This technology makes you expose methods as a Web Service so you can connect it (to the WS) from everywhere and use it (the methods). 此技术使您将方法公开为Web服务,因此您可以从任何地方连接它(到WS)并使用它(方法)。 But... you can't protect the data between server and client, like, you can send big files in a clear mode, etc... 但是...... 你无法保护服务器和客户端之间的数据,比如,你可以在清除模式下发送大文件等等......

[Note] you can protect the access to the web service using certificates, but it is a pain and quite complicated, normally in ASMX we use username / passsword to give access to a method (once again... in plain text!) [注意]你可以使用证书来保护对Web服务的访问,但这很麻烦而且非常复杂,通常在ASMX中我们使用username / passsword来访问一个方法(再一次......用纯文本!)

In WCF , you are in the different world about Web Services, and this is the best technology in .NET (so far) to expose Services ( can you see the difference... Services ! not Web Services ), WCF does not need IIS to run, it can run as a System Service on the server, using a console ambient (like command line), in TCP/IP mode, etc, so we say that WCF is a Service , not a Web Service. WCF中 ,您处于Web服务的不同世界,这是.NET(迄今为止)公开服务的最佳技术( 您能看到差异...... 服务 !而不是Web服务 ),WCF不需要IIS要运行,它可以作为服务器上的系统服务,使用控制台环境(如命令行),TCP / IP模式等运行,因此我们说WCF是服务 ,而不是Web服务。 Remember ASMX need IIS to run and will only run hosted in a Web Server. 请记住,ASMX需要运行IIS,并且只能在Web服务器中运行。

With WCF you can use SSL to encrypt the communication (to do that in ASMX you need to use WSE - Web Services Enhancements) and it is quite easy to implement it, you can send big files and securely (to do that in ASMX you need to use MTOM - Message Transmission Optimization Mechanism). 使用WCF,您可以使用SSL加密通信(要在ASMX中执行此操作,您需要使用WSE - Web服务增强功能)并且实现它非常容易,您可以安全地发送大文件(在ASMX中执行此操作,您需要使用MTOM - 消息传输优化机制)。

you can set the transmission preferences just changing one line of code, or even, if you prefer, change the XML configuration file, the security is much higher, etc, etc :) 您可以设置传输首选项只需更改一行代码,甚至,如果您愿意,可以更改XML配置文件,安全性更高等等:)

hope you get a better general overview with this, but there is much more. 希望你能得到一个更好的概述,但还有更多。

bottom line: to expose Web Services that you do not need to protect, you can use ASMX, no problem at all, but if you need to protect the communication somehow, do it in WCF! 底线:要公开您不需要保护的Web服务,您可以使用ASMX,完全没问题,但如果您需要以某种方式保护通信,请在WCF中进行!

link : you can read here some performance comparative between the 2 services 链接你可以在这里阅读这两项服务之间的一些性能比较

ASP.NET web services was Microsoft's first attempt at web services. ASP.NET Web服务是Microsoft首次尝试Web服务。

WCF replaces ASP.NET web servies and .NET remoting. WCF取代了ASP.NET Web服务和.NET远程处理。 WCF provides a common programming model that enables you to do what the two older technologies where capable of and much more including support for a wide range of protocols and security models. WCF提供了一个通用的编程模型,使您能够执行两种较旧的技术,包括对各种协议和安全模型的支持。

Go with WCF if you have the choice. 如果您有选择,请使用WCF。

ASP.NET webservices is OKAY - but it's limited to HTTP hosted in IIS only, and has other problems. ASP.NET webservices是好的 - 但它仅限于在IIS中托管的HTTP,并且还有其他问题。

WCF supports way more transport protocols (HTTP in various ways, TCP, MSMQ and more), has a lot richer security model (credentials, federated security), and offer options for hosting - self-hosting in a Windows app or service, in IIS or WAS and more. WCF支持更多传输协议(HTTP以各种方式,TCP,MSMQ等),具有更丰富的安全模型(凭据,联合安全性),并提供托管选项 - 在Windows应用程序或服务中自托管,在IIS中或者更多。

In short: if you're starting now - go learn WCF by all means ! 简而言之:如果你现在就开始 - 一定要学习WCF!

Marc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Visual Studio 2008中远程调试ASP.NET Web服务 - Remote debugging ASP.NET Web Service in Visual Studio 2008 创建一个ASP.NET Web服务,而不是WCF - Creating a ASP.NET web service, not WCF ASP.NET Web服务是否已被WCF Web服务取代? - Is ASP.NET web service replaced by WCF web service? Rest Web Service和启用了rest的wcf服务之间有什么区别? - What is the difference between Rest Web Service & rest enabled wcf service? WCF Web API和ASP.NET Web API之间有什么区别 - What's the difference between WCF Web API and ASP.NET Web API DDD服务和WCF服务之间有什么区别? - What is the difference between a DDD service and a WCF service? 如何处理ASP.NET网页和IIS中托管的WCF服务之间的跨域请求? - How to handle cross domain request between an asp.net web page and a WCF service hosted in IIS? 是什么使WCF测试客户端显示在WCF> WCF服务应用程序中,而不显示在ASP.NET Web应用程序项目中? - What makes WCF Test Client show up in WCF > WCF Service Application but not ASP.NET Web Application projects? 哪些场景需要 ASP.net Web API 来使用 WCF 服务? - What are some scenarios in which you need ASP.net Web API to consume a WCF Service? ASP.NET Web应用程序的WCF服务中的InvalidOperationException - InvalidOperationException in wcf service of asp.net web application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM