
























WCF的基本要点总结一下可以缩略为ABC:
1. A - Address (服务在哪里)
2. B - Binding (怎么才能访问服务呀?)
3. C - Contract (提供了哪些服务?)
Address - 用来唯一的标识一个服务。格式为[传输协议]://[IP地址,机器名或域名]:[端口号]。举几个例子
http://localhost:8080/MyService
net.tcp://localhost:8001/MyService
net.pipe://localhost/MyPipe
net.msmq://localhost/MyMsmq
Binding - 定义了与数据传输相关的传输协议,消息编码,通信模式,可靠性,安全性,事务,互操作性等信息。这些信息可以在兼容的前提下进行组合来达到需求,但是一般来说会产生很多组合,以至于开发人员无法选择。所以,WCF提供了最基本的9种标准的binding。基本上,这些标准binding能涵盖大多数应用范围。
|
Bingding |
Interoperability |
Security |
Session |
Transactions |
Duplex |
|
BasicHttpBinding |
Basic Profile 1.1 |
(None), Transport, Message |
None, (None) |
None |
n/a |
|
WSHttpBinding |
WS |
Transport, (Message), Mixed |
(None), Transport, Reliable Session |
(None), Yes |
n/a |
|
WSDualHttpBinding |
WS |
(Message) |
(Reliable Session) |
(None), Yes |
Yes |
|
WSFederationHttpBinding |
WS-Federation |
(Message) |
(None), Reliable Session |
(None), Yes |
No |
|
NetTcpBinding |
.NET |
(Transport), Message |
Reliable Session, (Transport) |
(None), Yes |
Yes |
|
NetNamedPipeBinding |
.NET |
(Transport) |
None, (Transport) |
(None), Yes |
Yes |
|
NetMsmqBinding |
.NET |
Message, (Transport), Both |
(None) |
(None), Yes |
No |
|
NetPeerTcpBinding |
Peer |
(Transport) |
(None) |
(None) |
Yes |
|
MsmqIntegrationBinding |
MSMQ |
(Transport) |
(None) |
(None), Yes |
n/a |
不过就算是9种,选择起来也比较困难。通过下面图,选择起来会轻松点

ontact - 定义了包含那些服务。WCF提供了4类代表不同的信息发布。
service contract - 定义了服务所提供的方法
data contract - 定义了与服务交互的数据类型
fault contact - 定义了服务的异常定义,以及处理异常的方式
message contract - 定义了一种可以直接访问的消息服务,用的不多
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。