官术网_书友最值得收藏!

Bindings

When a client and service communicate, there are several aspects to the communication.

  • Synchronous/asynchronous: Messages can be used in a request/response pattern or they can be used in asynchronous communication depending on whether the client waits for the response or not.
  • Transport protocol: The protocol used for transporting the messages can vary depending on the needs. Protocols such as HTTP, Transmission Control Protocol (TCP), Microsoft Message Queuing (MSMQ), and Inter-process communication (IPC) can be used.
  • Encoding: You have a choice on how to encode the messages. You can choose to use plain text if you want maximum interoperability. Alternatively, you can use binary encoding to speed up performance, or using the Message Transport Optimization Mechanism (MTOM) to handle larger payloads.
  • Security: There are also some options that can be used to handle security and authentication. Security can be implemented at the transport level, at the message level, or can be skipped altogether.

As you can imagine, keeping track of all of the options can be a little difficult, and making the right choice on how to configure the different settings is not easy. To solve this, WCF introduces bindings. A binding is merely a grouping of choices that deal with each aspect of the communication that we just discussed.

WCF supports several bindings out of the box. If these do not suffice, there is always the alternative of creating a custom binding of your own. The following are the most commonly used bindings:

  • NetTcpBinding: This uses the TCP protocol and is mainly used for cross-machine communication over an intranet. It is WCF-optimized and thus requires both the client and the server to use WCF.
  • BasicHttpBinding: This binding is used to expose a service as an ASMX web service so that older clients that comply with WS-I Basic Profile 1.1 are supported.
  • WsHttpBinding: This binding is used for communication over the Internet. It uses the HTTP and HTTPS protocols and complies with WS-* standards. So, any party that supports the WS-* standards is able to communicate with the service.
  • NetMsmqBinding: This type of binding will be used when support is needed for MSMQ queues. The NetMsmqBinding binding is actually a compact binding that does not provide all of the possible options to configure MSMQ. There are other bindings that provide more options.

Now that we have elaborated on some of the out-of-the-box bindings, you are probably asking yourself, how can I make sure I'm using the appropriate binding for my scenario? Well, the following flowchart may help you with this choice:

Bindings
主站蜘蛛池模板: 大新县| 军事| 凤阳县| 张掖市| 泾阳县| 滕州市| 岫岩| 宜都市| 广河县| 柳江县| 岫岩| 黄大仙区| 荥经县| 肇州县| 镇远县| 鹰潭市| 嘉鱼县| 凤城市| 兰溪市| 尖扎县| 银川市| 清涧县| 芒康县| 金川县| 石门县| 彭州市| 九龙城区| 广平县| 荥经县| 阜新| 西华县| 镇巴县| 蚌埠市| 久治县| 永兴县| 黑山县| 凤城市| 富宁县| 曲麻莱县| 新蔡县| 南陵县|