C# 使用 WCF 有什么好处?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/271326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are the benefits of using WCF?
提问by sontek
We currently just utilize soap webservices for all our communication but have been thinking about moving to WCF instead. What are the benefits of using it over an asmx service?
If we do go with a WCF service, can other languages still communicate with it? SOAP is standardized and all languages can interact with it.
Are there any really good examples of how to get started with WCF that show the benefits of it over soap?
我们目前只使用soap webservices 进行我们所有的通信,但一直在考虑转向WCF。在 asmx 服务上使用它有什么好处?
如果我们使用 WCF 服务,其他语言还能与之通信吗?SOAP 是标准化的,所有语言都可以与之交互。
是否有任何很好的例子说明如何开始使用 WCF 来显示它比肥皂的好处?
EDIT
编辑
- I just found thisquestion which is quite helpful.
- The Getting Started Tutorialis great.
采纳答案by Corbin March
There's a bit of a learning curve with WCF, but once you learn it it's no harder to implement than an asmx web services. One advantage is you can easily switch protocols and serialization from binary remoting all the way to web protocols. It's also easy to host either in IIS or out.
Other languages can communicate with the web protocols. Binary, not so much...
I just dug into the Getting Started Tutorial. It does a good job of showing the relative ease-of-use. From there, take a look at Hostingand more detailed Features.
回答by Marc Bollinger
WCF is not a replacement for SOAP, and indeed, SOAP can be used as the serialization format between endpoints for communication. SOAP the standard also doesn't really define what goes in the message body, so in the case of WCF-to-WCF communication, a SOAP envelope is used, but the content is binary, so there's your primary advantage, at least in terms of performance. Another advantage is that the programming model of WCF is, or at least is intended to be, much more straightforward; especially since it sounds like you're really just using Web Services to communicate internally. In this case, most of the work would be up front, configuring endpoints (though consuming asmx WSDLs is obviously very easy in .NET).
WCF 不是 SOAP 的替代品,实际上,SOAP 可以用作端点之间的序列化格式以进行通信。SOAP 标准也没有真正定义消息体中的内容,因此在 WCF 到 WCF 通信的情况下,使用了 SOAP 信封,但内容是二进制的,因此这是您的主要优势,至少在术语方面的性能。另一个优点是 WCF 的编程模型,或者至少是打算,更加直接;尤其是因为听起来您实际上只是在使用 Web 服务进行内部通信。在这种情况下,大部分工作都是预先进行的,即配置端点(尽管在 .NET 中使用 asmx WSDL 显然非常容易)。
I'm no expert in WCF, but what I do know has been from .NET user group presentations by Juval Lowy (who wrote the O'Reilly WCF book), his sitehas a decent amount of information in the way of screencasts and samples in the Resources section, in addition to the Microsoft sites (have you checked Channel9?).
我不是 WCF 方面的专家,但我所知道的内容来自 Juval Lowy(他撰写了 O'Reilly WCF 书籍)的 .NET 用户组演示,他的网站以截屏视频和示例的方式提供了大量信息在资源部分,除了 Microsoft 站点(您检查过Channel9吗?)。
回答by Chris S
Based on this MSDN articlethat is linked in the question, WCF supports more than just SOAP. It has support for:
根据问题中链接的这篇 MSDN 文章,WCF 不仅支持 SOAP。它支持:
BasicHttpBinding
Interoperability with Web services and clients supporting the WS-BasicProfile 1.1 and Basic Security Profile 1.0.WSHttpBinding
Interoperability with Web services and clients that support the WS-* protocols over HTTP.WSDualHttpBinding
Duplex HTTP communication, by which the receiver of an initial message does not reply directly to the initial sender, but may transmit any number of responses over a period of time by using HTTP in conformity with WS-* protocols.WSFederationBinding
HTTP communication, in which access to the resources of a service can be controlled based on credentials issued by an explicitly-identified credential provider.NetTcpBinding
Secure, reliable, high-performance communication between WCF software entities across a network.NetNamedPipeBinding
Secure, reliable, high-performance communication between WCF software entities on the same machine.NetMsmqBinding
Communication between WCF software entities by using MSMQ.MsmqIntegrationBinding
Communication between a WCF software entity and another software entity by using MSMQ.NetPeerTcpBinding
Communication between WCF software entities by using Windows Peer-to-Peer Networking.
BasicHttpBinding
与支持 WS-BasicProfile 1.1 和 Basic Security Profile 1.0 的 Web 服务和客户端的互操作性。WSHttpBinding
与通过 HTTP 支持 WS-* 协议的 Web 服务和客户端的互操作性。WSDualHttpBinding
双工HTTP 通信,初始消息的接收方不直接回复初始发送方,但可以使用符合WS-* 协议的HTTP 在一段时间内发送任意数量的响应。WSFederationBinding
HTTP 通信,其中对服务资源的访问可以基于显式标识的凭据提供程序颁发的凭据进行控制。NetTcpBinding
通过网络在 WCF 软件实体之间进行安全、可靠、高性能的通信。NetNamedPipeBinding
在同一台机器上的 WCF 软件实体之间进行安全、可靠、高性能的通信。NetMsmqBinding
使用 MSMQ 在 WCF 软件实体之间进行通信。MsmqIntegrationBinding
使用 MSMQ 在 WCF 软件实体和另一个软件实体之间进行通信。NetPeerTcpBinding
使用 Windows 对等网络在 WCF 软件实体之间进行通信。