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

时间:2022-12-03 23:00:33

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服务中使用...显然,WCF和ASP.NET Web服务。有什么不同?我刚刚开始接收WCF并且过去曾经接触过一些Web服务,但我当然不是专家。

3 个解决方案

#1


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 Method被称为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). But... you can't protect the data between server and client, like, you can send big files in a clear mode, etc...

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

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

在WCF中,您处于Web服务的不同世界,这是.NET(迄今为止)公开服务的最佳技术(您能看到差异......服务!而不是Web服务),WCF不需要IIS要运行,它可以作为服务器上的系统服务运行,使用控制台环境(如命令行),TCP / IP模式等,所以我们说WCF是服务,而不是Web服务。请记住,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

链接:你可以在这里阅读这两项服务之间的一些性能比较

#2


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 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取代了ASP.NET Web服务和.NET远程处理。 WCF提供了一种通用编程模型,使您能够执行两种旧技术,包括对各种协议和安全模型的支持。

Go with WCF if you have the choice.

如果您有选择,请使用WCF。

#3


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

#1


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 Method被称为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). But... you can't protect the data between server and client, like, you can send big files in a clear mode, etc...

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

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

在WCF中,您处于Web服务的不同世界,这是.NET(迄今为止)公开服务的最佳技术(您能看到差异......服务!而不是Web服务),WCF不需要IIS要运行,它可以作为服务器上的系统服务运行,使用控制台环境(如命令行),TCP / IP模式等,所以我们说WCF是服务,而不是Web服务。请记住,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

链接:你可以在这里阅读这两项服务之间的一些性能比较

#2


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 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取代了ASP.NET Web服务和.NET远程处理。 WCF提供了一种通用编程模型,使您能够执行两种旧技术,包括对各种协议和安全模型的支持。

Go with WCF if you have the choice.

如果您有选择,请使用WCF。

#3


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