ASP.NET Web 方法和 WCF 服务有什么区别?

发布于 2024-07-06 18:33:51 字数 43 浏览 7 评论 0原文

我是 .Net 的新手,不明白其中的区别。 有人能指出我正确的方向吗?

I'm new to .Net and do not understand the difference. Can someone point me in the right direction?

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

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

发布评论

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

评论(9

舞袖。长 2024-07-13 18:33:51

ASP.NET Web 服务是为构建通过 HTTP 使用简单对象访问协议 (SOAP) 发送和接收消息的应用程序而开发的。

WCF 用于使 .NET Framework 应用程序能够与其他软件实体交换消息。 默认情况下使用 SOAP,但消息可以采用任何格式,并使用任何传输协议进行传送。

您可以将 ASP.NET Web 服务视为 WCF 服务的子集。

此处是比较这两个框架的链接。

ASP.NET Web services was developed for building applications that send and receive messages by using the Simple Object Access Protocol (SOAP) over HTTP.

WCF is for enabling .NET Framework applications to exchange messages with other software entities. SOAP is used by default, but the messages can be in any format, and conveyed by using any transport protocol.

You can view ASP.NET web services as a subset of WCF services.

Here is a link comparing the two frameworks.

℉絮湮 2024-07-13 18:33:51

很容易知道其中的差异。

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

该技术使您可以将函数公开为 Web 服务,以便您可以从任何地方连接它并使用它。 但是...您无法保护服务器和客户端之间的数据,您可以清楚地发送大文件并知道发生了什么,等等...

[注意]您可以保护对Web服务的访问使用证书,但这很复杂,但通常,在 ASMX 中我们使用用户名/密码。

在 WCF 中,您处于 Web 服务的不同世界,这是 .NET 中公开服务的最佳技术(您能看出区别吗... 服务!不是Web服务),WCF不需要IIS来运行,它可以作为服务器上的系统服务运行,使用控制台环境(如命令行)等,所以我们说WCF是一个服务不是 Web 服务。 请记住 ASMX 需要 IIS 才能运行。

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

您只需更改一行代码即可设置传输首选项,安全性更高,等等:)

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

底线:要公开不需要保护的 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)

That technology makes you expose functions as a Web Service so you can connect it from everywhere and use it. But... you can't protect the data between server and client, you can send big files clear and know what happend, etc...

[Note] you can protect the access to the web service using certificates, but it is complicated but normally, in ASMX we use username / passsword.

in WCF, you are in the different world about Web Services,and this s the best technology in .NET 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), etc, so we say that WCF is a Service not Web Service. Remember ASMX need IIS to run.

with WCF you can use SSL to encrypt the communication (to do that in ASMX you need to use WSE - Web Services Enhancements), 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, 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

℡Ms空城旧梦 2024-07-13 18:33:51

它们是两种不同的编写服务的框架。 WCF 通常更加灵活,并提供可配置的选项,包括使用什么协议、如何托管服务以及各种安全选项。 ASMX 提供基于 SOAP 的服务。 一般来说,WCF 也更性能。 一般来说,ASMX 更容易使用,并且学习曲线通常更短。

这里是MSDN 论坛关于该主题的讨论。
以下是 ASMX 和 < a href="http://msdn.microsoft.com/en-us/library/ms734712.aspx" rel="noreferrer">WCF。

They are two different frameworks for writing services. WCF is generally more flexible and provides configurable options for what protocols are used, how the service is hosted and a variety of security options. ASMX offers SOAP based services. Generally WCF is also more performant. In general ASMX is easier to use and generally has less of a learning curve.

Here is a MSDN forum discussion on the topic.
Here are the getting started pages for ASMX and WCF.

爱已欠费 2024-07-13 18:33:51

除了上述响应之外,WCF 的创建是为了取代 .NET 3.0 及更高版本中的 .NET Remoting。 除了SOAP、REST、POX等各种格式(例如XML和JSON)的Web服务之外,WCF还提供MSMQ和命名管道。 如上所述,ASMX 仅提供基于 SOAP 的 XML Web 服务。

您需要深入研究 .NET Remoting其他类型的通信协议。 有关更多信息,您应该查看Pro C# 2008 和 .NET 3.5 Framework 。 这是一个很棒的资源,您可以获取以前书籍中介绍 .NET Remoting 和其他替换功能的章节。

In addition to the above responses, WCF was created to replace .NET Remoting in .NET 3.0 and beyond. In addition to SOAP, REST, POX, etc. web services in various formats (e.g. XML and JSON), WCF also offers MSMQ and Named Pipes. ASMX, as mentioned above, provides only SOAP-based XML web services.

You would need to delve into .NET Remoting for other types of communication protocols. For additional information, you should check out Pro C# 2008 and the .NET 3.5 Framework. It's a great resource, and you can get the chapters from the previous books that cover .NET Remoting, and other replaced features.

苏璃陌 2024-07-13 18:33:51

这是一个新的、重大的区别:微软现在认为 ASMX Web 服务是“传统”技术。 请参阅“使用 ASP.NET 和 XML Web 服务客户端创建的 XML Web 服务 ”。

Here's a new, big, difference: Microsoft now considers ASMX web services to be "legacy" technology. See "XML Web Services Created Using ASP.NET and XML Web Service Clients".

标点 2024-07-13 18:33:51

Web 服务

  1. 它只能通过 HTTP 访问
  2. 它在无状态环境中工作

WCF

WCF 很灵活,因为它的服务可以托管在不同类型的应用程序中。 下面列出了托管 WCF 服务的几种常见方案:

  • IIS
  • WAS
  • 自托管
  • 托管 Windows 服务

Web Services

  1. It Can be accessed only over HTTP
  2. It works in stateless environment

WCF

WCF is flexible because its services can be hosted in different types of applications. The following lists several common scenarios for hosting WCF services:

  • IIS
  • WAS
  • Self-hosting
  • Managed Windows Service
楠木可依 2024-07-13 18:33:51

它们是两个不同的东西。 WCF 是一个更通用的框架,通过它您可以编写一个服务类型组件并以多种方式部署它(甚至作为 Asp.Net Web 服务)。

这是关于此的简短主题 http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/2d6a7ff2-f15c-4599-a389-a81cfffcc852/

They are two different things all together. WCF is a more generic framework through which you can write one service type component and deploy it in many ways (even as an Asp.Net Web Service).

Here's a brief thread about this http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/2d6a7ff2-f15c-4599-a389-a81cfffcc852/

勿忘初心 2024-07-13 18:33:51

我有同样的问题。

我发现《Microsoft Windows Communication Foundation Step by Step》这本书非常好。

如果您只是想使用 WCF 执行传统的 Web 服务操作,那么该书的第 1 章将准确地向您展示如何执行此操作(编写服务、测试、部署、使用服务)。

它是为 VS2005 编写的,但我正在使用 vs2008,发现它更容易。

WCF 还有很多内容,但这本书是一个好的开始。

I had the same problem.

I found the book Microsoft Windows Communication Foundation Step by Step to be really good.

If you just want to do the traditional webservice thing using WCF, then Chapter 1 of that book will show you exactly how to do that (write service, test, deploy, use service).

Its written for VS2005, but I'm using vs2008 and found it even easier.

There's a lot more to WCF, but that book is a good start.

怪我闹别瞎闹 2024-07-13 18:33:51

下面列出了 Web 服务和 WCF 之间的主要区别。

Web 服务:Web 服务是一种旨在通过 Internet 与其他应用程序直接交互的应用程序。

1) [WebService]和[WebMethod]属性定义了Web服务和方法。
2) 只能通过HTTP访问。
3) 托管在 IIS 中。
4) 支持安全服务。
5) 不能多线程。
6) 仅使用 Soap 或 XML。
7)System.Xml.serialization名称空间用于序列化

WCF:Windows Communication Foundation(代号Indigo)是一个编程平台和运行时系统,用于构建、配置和部署网络分布式服务。

1) [ServiceContract]和[OperationContract]属性定义了Web服务和方法。
2) 通过HTTP、TCP、MSMQ、P2P、命名管道访问
3) 托管在 IIS、自托管、WAS 和 Windows 服务中。
4) 可以通过服务行为类实现多线程。
5) System.Runtime.Serialization命名空间用于序列化
6) 支持不同类型的绑定,如 BasicHttpBinding、WSHttpBinding、WSDualHttpBinding 等。
7) 支持安全服务、可靠的消息传递、事务、AJAX 和 REST 支持

Main Differences between Web service and WCF are listed below.

Web Service : Web Service is an application that is designed to interact directly with other applications over the internet.

1) [WebService] and [WebMethod] attributes defines a web service and methods.
2) It Can be accessed only over HTTP.
3) Hosted in IIS.
4) Support security services.
5) Can not be multithreaded.
6) Only Used Soap or XML.
7) System.Xml.serialization name space is used for serialization

WCF :Windows Communication Foundation (Code named Indigo) is a programming platform and runtime system for building, configuring and deploying network-distributed services.

1) [ServiceContract] and [OperationContract] attributes defines a web service and methods.
2) Accessed through HTTP, TCP, MSMQ, P2P, Named pipes
3) Hosted in IIS, Self-Hosting ,WAS and Windows Service.
4) Can be multithreaded via service behavior class.
5) System.Runtime.Serialization namespace is used for serialization
6) Supports different type of bindings like BasicHttpBinding, WSHttpBinding,WSDualHttpBinding etc.
7) Support security services, reliable messaging, transactions, AJAX and REST Support

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