Επεξεργασία

Κοινή χρήση μέσω


System-provided bindings

Bindings specify the communication mechanism to use when talking to an endpoint and indicate how to connect to an endpoint. A binding contains the following elements:

  • The protocol stack determines the security, reliability, and context flow settings to use for messages that are sent to the endpoint.

  • The transport determines the underlying transport protocol to use when sending messages to the endpoint, for example, TCP or HTTP.

  • The encoding determines the wire encoding to use for messages that are sent to the endpoint. For example, text/XML, binary, or Message Transmission Optimization Mechanism (MTOM).

This article presents all of the system-provided Windows Communication Foundation (WCF) bindings. If none of these bindings meets the exact criteria for your application, you can create a custom binding. For more information about creating custom bindings, see Custom Bindings.

A secure and interoperable binding that supports the WS-Federation protocol enables organizations that are in a federation to efficiently authenticate and authorize users.

Important

Always select a binding that includes security. By default, all bindings except the <basicHttpBinding> element have security enabled. If you do not select a secure binding or disable security, be sure to protect your data in some other manner, such as storing in a secured data center or on an isolated network.

Important

Never use duplex contracts with bindings that do not support security or that have security disabled unless you secure the data by some other means.

The following bindings ship with WCF:

Binding Configuration Element Description
BasicHttpBinding <basicHttpBinding> A binding that is suitable for communicating with WS-Basic Profile-conformant Web services, for example, ASP.NET Web services (ASMX)-based services. This binding uses HTTP as the transport and text/XML as the default message encoding.
WSHttpBinding <wsHttpBinding> A secure and interoperable binding that is suitable for non-duplex service contracts.
WSDualHttpBinding <wsDualHttpBinding> A secure and interoperable binding that is suitable for duplex service contracts or communication through SOAP intermediaries.
WSFederationHttpBinding <wsFederationHttpBinding> A secure and interoperable binding that supports the WS-Federation protocol, which enables organizations that are in a federation to efficiently authenticate and authorize users.
NetHttpBinding <netHttpBinding> A binding designed for consuming HTTP or WebSocket services that uses binary encoding by default.
NetHttpsBinding <netHttpsBinding> A secure binding designed for consuming HTTP or WebSocket services that uses binary encoding by default.
NetTcpBinding <netTcpBinding> A secure and optimized binding suitable for cross-machine communication between WCF applications.
NetNamedPipeBinding <netNamedPipeBinding> A secure, reliable, optimized binding that is suitable for on-machine communication between WCF applications.
NetMsmqBinding <netMsmqBinding> A queued binding that is suitable for cross-machine communication between WCF applications.
NetPeerTcpBinding <netPeerTcpBinding> A binding that enables secure, multiple machine communication.
MsmqIntegrationBinding <msmqIntegrationBinding> A binding that is suitable for cross-machine communication between a WCF application and existing Message Queuing applications.
BasicHttpContextBinding <basicHttpContextBinding> A binding suitable for communicating with WS-Basic Profile conformant Web services that enables HTTP cookies to be used to exchange context.
NetTcpContextBinding <netTcpContextBinding> A secure and optimized binding suitable for cross-machine communication between WCF applications that enables SOAP headers to be used to exchange context.
WebHttpBinding <webHttpBinding> A binding used to configure endpoints for WCF Web services that are exposed through HTTP requests instead of SOAP messages.
WSHttpContextBinding <wsHttpContextBinding> A secure and interoperable binding suitable for non-duplex service contracts that enables SOAP headers to be used to exchange context.
UdpBinding <udpBinding> A binding to use when sending a burst of simple messages to a large number of clients simultaneously.

The following table shows the features of each of the system-provided bindings. The bindings are found in the table columns; the features are listed in the rows and described in a second table. The following table provides a key for the binding abbreviations used. To select a binding, determine which column satisfies all of the row features you need.

Binding Interoperability Security (Default) Session
(Default)
Transactions Duplex Encoding (Default) Streaming
(Default)
BasicHttpBinding Basic Profile 1.1 (None), Transport, Message, Mixed (None) (None) n/a Text, (MTOM) Yes
(buffered)
WSHttpBinding WS Transport, (Message), Mixed (None), Reliable Session, Security Session (None), Yes n/a (Text), MTOM No
WSDualHttpBinding WS (Message), None (Reliable Session), Security Session (None), Yes Yes (Text), MTOM No
WSFederationHttpBinding WS-Federation (Message), Mixed, None (None), Reliable Session, Security Session (None), Yes No (Text), MTOM No
NetHttpBinding .NET (None), Transport, Message, TransportWithMessageCredential, TransportCredentialOnly See note below None See note below (Binary), Text, MTOM Yes (buffered)
NetHttpsBinding .NET (Transport), TransportWithMessageCredential See note below None See note below (Binary), Text, MTOM Yes
(buffered)
NetTcpBinding .NET (Transport), Message, None, Mixed (Transport), Reliable Session, Security Session (None), Yes Yes Binary Yes
(buffered)
NetNamedPipeBinding .NET (Transport), None None, (Transport) (None), Yes Yes Binary Yes
(buffered)
NetMsmqBinding .NET Message, (Transport), None (None), Transport None, (Yes) No Binary No
NetPeerTcpBinding Peer (Transport) (None) (None) Yes No
MsmqIntegrationBinding MSMQ (Transport) (None) None, (Yes) n/a n/a No
BasicHttpContextBinding Basic Profile 1.1 (None), Transport, Message, Mixed (None) (None) n/a Text, (MTOM) Yes
(buffered)
NetTcpContextBinding .NET (Transport), Message, None, Mixed (Transport), Reliable Session, Security Session (None), Yes Yes Binary Yes
(buffered)
WSHttpContextBinding WS Transport, (Message), Mixed (None), Reliable Session, Security Session (None), Yes n/a Text, (MTOM) No
UdpBinding

Note: Interoperability can be achieved by implementing the standard SOAP-over-UDP spec which this binding implements.
.NET (None) (None) (None) n/a (Text) No

Important

NetHttpBinding is a binding designed for consuming HTTP or WebSocket services and uses binary encoding by default. NetHttpBinding detects whether it's used with a request-reply contract or duplex contract and changes its behavior to match; it uses HTTP for request-reply and WebSockets for duplex. This behavior can be overridden using the WebSocketTransportUsage binding setting: WhenDuplex - This is the default value and behaves as described above. Never - This prevents WebSockets from being used. Attempting to use a duplex contract with this setting results in an exception. Always - This forces WebSockets to be used even for request-reply contracts. NetHttpBinding supports reliable sessions in both HTTP mode and WebSocket mode. In WebSocket mode sessions are provided by the transport.

The following table explains the features listed in the previous table.

Feature Description
Interoperability Type Names the protocol or technology with which the binding ensures interoperation.
Security Specifies how the channel is secured:
- None: The SOAP message isn't secured and the client isn't authenticated.
- Transport: Security requirements are satisfied at the transport layer.
- Message: Security requirements are satisfied at the message layer.
- Mixed: Claims are carried in the message; integrity and confidentiality requirements are satisfied by the transport layer.
Session Specifies whether this binding supports session contracts.
Transactions Specifies whether transactions are enabled.
Duplex Specifies whether duplex contracts are supported. Note that this feature requires support for Sessions in the binding.
Encoding Specifies the wire format of the message. Allowable values include:
- Text: for example UTF-8.
- Binary
- Message Transmission Optimization Mechanism (MTOM): A method for efficiently encoding binary XML elements within the context of a SOAP envelope.
Streaming Specifies whether streaming is supported for incoming and outgoing messages. Use the TransferMode property on the binding to set the value. The allowable values include:
- Buffered: The request and response messages are both buffered.
- Streamed: The request and response messages are both streamed.
- StreamedRequest: The request message is streamed and the response message is buffered.
- StreamedResponse: The request message is buffered and the response message is streamed.

See also