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

发布于 2024-07-18 04:18:26 字数 107 浏览 3 评论 0原文

我发现有两个选项可以在 Web 服务中使用......显然是 WCF 和 ASP.NET Web 服务。 有什么不同? 我最近才开始接触 WCF,过去也接触过一些 Web 服务,但我当然不是专家。

I see that there are two options that I know can be used in web services... WCF obviously, and ASP.NET Web Services. 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

眼泪淡了忧伤 2024-07-25 04:18:26

很容易知道其中的差异。

ASP.NET Web Method 被称为 ASMX [因为文件扩展名](检查 4GuysFromRolla 关于这一点,他们有一个 好教程

该技术使您可以将方法公开为 Web 服务,以便您可以从任何地方连接它(到 WS)并使用它(方法)。 但是...您无法保护服务器和客户端之间的数据,例如,您可以以清晰模式发送大文件等...

[注意]您可以保护对网络的访问使用证书的服务,但这很痛苦而且相当复杂,通常在 ASMX 中我们使用用户名/密码来访问方法(再次......以纯文本形式!)

WCF 中,您是在关于 Web 服务的不同世界中,这是 .NET 中(迄今为止)公开服务的最佳技术(你能看出区别吗... 服务!不是Web Services),WCF不需要IIS来运行,它可以作为服务器上的系统服务运行,使用控制台环境(如命令行),以TCP/IP模式等,所以我们说 WCF 是一个服务,而不是一个 Web 服务。 请记住,ASMX 需要 IIS 才能运行,并且只能在 Web 服务器上托管运行。

使用 WCF,您可以使用 SSL 来加密通信(要在 ASMX 中执行此操作,您需要使用 WSE - Web 服务增强功能),并且实现它非常容易,您可以安全地发送大文件(要在 ASMX 中执行此操作,您需要使用MTOM - 消息传输优化机制)。

您只需更改一行代码即可设置传输首选项,或者甚至,如果您愿意,可以更改 XML 配置文件,安全性要高得多,等等:)

希望您对此有一个更好的总体概述,但是有多得多。

底线:要公开不需要保护的 Web 服务,您可以使用 ASMX,完全没问题,但如果您需要以某种方式保护通信,请在 WCF 中进行!

链接您可以在此处阅读这两种服务之间的一些性能比较

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)

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). 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!)

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. Remember ASMX need IIS to run and will only run hosted in a Web Server.

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).

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 :)

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!

link: you can read here some performance comparative between the 2 services

折戟 2024-07-25 04:18:26

ASP.NET Web 服务是 Microsoft 在 Web 服务方面的首次尝试。

WCF 取代了 ASP.NET Web 服务和 .NET 远程处理。 WCF 提供了一个通用的编程模型,使您能够完成两种较旧技术的功能,并且还包括对各种协议和安全模型的支持。

如果有选择的话,请选择 WCF。

ASP.NET web services was Microsoft's first attempt at web services.

WCF replaces ASP.NET web servies and .NET remoting. 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.

Go with WCF if you have the choice.

南…巷孤猫 2024-07-25 04:18:26

ASP.NET Web 服务还不错,但它仅限于 IIS 中托管的 HTTP,并且还有其他问题。

WCF 支持更多的传输协议(各种方式的 HTTP、TCP、MSMQ 等),具有更丰富的安全模型(凭据、联合安全性),并提供托管选项 - 在 Windows 应用程序或服务、IIS 中自托管或WAS等等。

简而言之:如果您现在就开始 - 一定要学习 WCF!

马克

ASP.NET webservices is OKAY - but it's limited to HTTP hosted in IIS only, and has other problems.

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.

In short: if you're starting now - go learn WCF by all means !

Marc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文