Visual Studio选项有什么区别:ASP.NET Web服务和WCF服务(What is the difference between the Visual Studio Options: A

编程入门 行业动态 更新时间:2024-10-25 21:25:49
Visual Studio选项有什么区别:ASP.NET Web服务和WCF服务(What is the difference between the Visual Studio Options: ASP.NET Web Service and WCF Service)

我看到有两个选项,我知道可以在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.

最满意答案

知道这些差异很容易。

ASP.NET Web Method被称为ASMX [因为文件扩展名](请查看4GuysFromRolla,他们有一个很好的教程 )

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

[注意]你可以使用证书来保护对Web服务的访问,但这很麻烦而且非常复杂,通常在ASMX中我们使用username / passsword来访问一个方法(再一次......用纯文本!)

WCF中 ,您处于Web服务的不同世界,这是.NET(迄今为止)公开服务的最佳技术( 您能看到差异...... 服务 !而不是Web服务 ),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

更多推荐

本文发布于:2023-08-03 19:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1395701.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么区别   选项   ASP   Studio   Visual

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!