Skip to content

Latest commit

 

History

History
305 lines (250 loc) · 18.2 KB

custombinding.md

File metadata and controls

305 lines (250 loc) · 18.2 KB
description title ms.date ms.assetid
Learn more about: <customBinding>
<customBinding>
03/30/2017
9da4f960-f64e-4d8a-894d-2b09eba5ce4b

<customBinding>

Provides full control over the messaging stack for the user.

<configuration>
  <system.serviceModel>
    <bindings>
      <customBinding>

Syntax

<customBinding>
  <binding name="String"
           closeTimeout="TimeSpan"
           openTimeout="TimeSpan"
           receiveTimeout="TimeSpan"
           sendTimeout="TimeSpan">
    <compositeDuplex clientBaseAddress="Uri" />
    <reliableSession acknowledgementInterval="TimeSpan"
                     advancedFlowControl="Boolean"
                     bufferedMessagesQuota="Integer"
                     inactivityTimeout="TimeSpan"
                     maxPendingChannels="Integer"
                     maxRetryCount="Integer"
                     ordered="Boolean" />
    <pnrpPeerResolver />
    <windowsStreamSecurity protectionLevel="None/Sign/EncryptAndSign" />
    <sslStreamSecurity requireClientCertificate="Boolean" />
    <transactionFlow transactionProtocol="OleTransactions/WSAtomicTransactionOctober2004" />
    <security defaultAlgorithmSuite="Basic128/Basic192/Basic256/Basic128Rsa15/Basic256Rsa15/TripleDes/TripleDesRsa15/Basic128Sha256/Basic192Sha256/TripleDesSha256/Basic128Sha256Rsa15/Basic192Sha256Rsa15/Basic256Sha256Rsa15/TripleDesSha256Rsa15"
              authenticationMode="UserNameForAnonymous"
              contextMode="Cookie"
              defaultProtectionLevel="Sign"
              enableKeyDerivation="false"
              keyEntropyMode="ClientEntropy"
              messageProtectionOrder="SignBeforeEncryptAndEncryptSignature"
              securityVersion="WSSecurityXXX2005">
      <localClientSettings cacheCookies="false"
                           detectReplays="false"
                           maxCookieCachingTime="00:07:24" />
      <localServiceSettings replayCacheSize="9"
                            maxClockSkew="00:00:03"
                            replayWindow="00:07:22.2190000" />
    </security>
    <binaryMessageEncoding maxReadPoolSize="Integer"
                           maxWritePoolSize="Integer"
                           maxSessionSize="Integer" />
    <httpsTransport manualAddressing="Boolean"
                    maxMessageSize="Integer"
                    authenticationScheme="Negotiate"
                    bypassProxyOnLocal="Boolean"
                    hostNameComparisonMode="Exact"
                    mapAddressingHeadersToHttpHeaders="Boolean"
                    proxyaddress="Uri"
                    realm="String"
                    requireClientCertificate="Boolean" />
    <peerTransport manualAddressing="false"
                   maxMessageSize="20002"
                   listenIPAddress="202.10.1.9"
                   messageAuthentication="false"
                   peerNodeAuthenticationMode="None"
                   port="1000" />
    <security defaultAlgorithmSuite="Basic128/Basic192/Basic256/Basic128Rsa15/Basic256Rsa15/TripleDes/TripleDesRsa15/Basic128Sha256/Basic192Sha256/TripleDesSha256/Basic128Sha256Rsa15/Basic192Sha256Rsa15/Basic256Sha256Rsa15/TripleDesSha256Rsa15"
              authenticationMode="UserNameForAnonymous"
              bootstrapBindingConfiguration="String"
              bootstrapBindingSectionName="String"
              defaultProtectionLevel="None/Sign/EncryptAndSign"
              requireDerivedKeys="Boolean"
              securityHeaderLayout="Strict/Lax/LaxTimestampFirst/LaxTimestampLast"
              includeTimestamp="Boolean"
              keyEntropyMode="ClientEntropy/ServerEntropy/CombinedEntropy"
              messageProtectionOrder="SignBeforeEncrypt/SignBeforeEncryptAndEncryptSignature/EncryptBeforeSign"
              protectTokens="Boolean"
              requireSecurityContextCancellation="Boolean"
              securityVersion=" WSSecurityJan2004/WSSecurityXXX2005"
              requireSignatureConfirmation="Boolean">
      <localClientSettings cacheCookies="Boolean"
                           detectReplays="Boolean"
                           replayCacheSize="Integer"
                           maxClockSkew="TimeSpan"
                           maxCookieCachingTime="TimeSpan"
                           replayWindow="TimeSpan"
                           sessionKeyRenewalInterval="TimeSpan"
                           sessionKeyRolloverInterval="TimeSpan"
                           reconnectOnTransportFailure="Boolean"
                           timestampValidityDuration="TimeSpan"
                           cookieRenewalThresholdPercentage="Integer" />
      <localServiceSettings detectReplays="Boolean"
                            issuedCookieLifeTime="TimeSpan"
                            maxStatefulNegotiations="Integer"
                            replayCacheSize="Integer"
                            maxClockSkew="TimeSpan"
                            negotiationTimeout="TimeSpan"
                            replayWindow="TimeSpan"
                            inactivityTimeout="TimeSpan"
                            sessionKeyRenewalInterval="TimeSpan"
                            sessionKeyRolloverInterval="TimeSpan"
                            reconnectOnTransportFailure="Boolean"
                            maxConcurrentSessions="Integer"
                            timestampValidityDuration="TimeSpan" />
      <federationParameters trustVersion="WSTrustApr2004/WSTrustFeb2005" />
    </security>
    <security defaultAlgorithmSuite="Basic128/Basic192/Basic256/Basic128Rsa15/Basic256Rsa15/TripleDes/TripleDesRsa15/Basic128Sha256/Basic192Sha256/TripleDesSha256/Basic128Sha256Rsa15/Basic192Sha256Rsa15/Basic256Sha256Rsa15/TripleDesSha256Rsa15"
              authenticationMode="UserNameForAnonymous"
              bootstrapBindingConfiguration="String"
              bootstrapBindingSectionName="String"
              defaultProtectionLevel="None/Sign/EncryptAndSign"
              requireDerivedKeys="Boolean"
              securityHeaderLayout="Strict/Lax/LaxTimestampFirst/LaxTimestampLast"
              includeTimestamp="Boolean"
              keyEntropyMode="ClientEntropy/ServerEntropy/CombinedEntropy"
              messageProtectionOrder="SignBeforeEncrypt/SignBeforeEncryptAndEncryptSignature/EncryptBeforeSign"
              protectTokens="Boolean"
              requireSecurityContextCancellation="Boolean"
              securityVersion=" WSSecurityJan2004/WSSecurityXXX2005"
              requireSignatureConfirmation="Boolean" >
      <localClientSettings cacheCookies="Boolean"
                           detectReplays="Boolean"
                           replayCacheSize="Integer"
                           maxClockSkew="TimeSpan"
                           maxCookieCachingTime="TimeSpan"
                           replayWindow="TimeSpan"
                           sessionKeyRenewalInterval="TimeSpan"
                           sessionKeyRolloverInterval="TimeSpan"
                           reconnectOnTransportFailure="Boolean"
                           timestampValidityDuration="TimeSpan"
                           cookieRenewalThresholdPercentage="Integer" />
      <localServiceSettings detectReplays="Boolean"
                           issuedCookieLifeTime="TimeSpan"
                           maxStatefulNegotiations="Integer"
                           replayCacheSize="Integer"
                           maxClockSkew="TimeSpan"
                           negotiationTimeout="TimeSpan"
                           replayWindow="TimeSpan"
                           inactivityTimeout="TimeSpan"
                           sessionKeyRenewalInterval="TimeSpan"
                           sessionKeyRolloverInterval="TimeSpan"
                           reconnectOnTransportFailure="Boolean"
                           maxConcurrentSessions="Integer"
                           timestampValidityDuration="TimeSpan" />
      <federationParameters trustVersion="WSTrustApr2004/WSTrustFeb2005" />
      <genericIssuedTokenParameters>
        <localIssuerIssuedTokenParameters keyType="SymmetricKey/PublicKey"
                                          keySize="Integer"
                                          tokenType="String" />
        <issuedTokenParametersEndpointAddress address="URI"
                                              bindingConfiguration="String"
                                              binding="String" />
        <issuedTokenClient localIssuerChannelBehaviors="String"
                           cacheIssuedTokens="Boolean"
                           maxIssuedTokenCachingTime="TimeSpan"
                           keyEntropyMode="ClientEntropy/ServerEntropy/CombinedEntropy" />
        <issuedTokenClientBehavior issuerAddress="String"
                                   behaviorConfiguration="String" />
        <issuedTokenClientBehavior address="URI"
                                   bindingConfiguration="String"
                                   binding="String" />
      </genericIssuedTokenParameters>
    </security>
  </binding>
</customBinding>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements

Attributes

Attribute Description
closeTimeout A xref:System.TimeSpan value that specifies the interval of time provided for a close operation to complete. This value should be greater than or equal to xref:System.TimeSpan.Zero. The default is 00:01:00.
name A string that contains the configuration name of the binding. This value is a user-defined string that acts as the identification string for the custom binding. Starting with .NET Framework 4, bindings and behaviors are not required to have a name. For more information about default configuration and nameless bindings and behaviors, see Simplified Configuration and Simplified Configuration for WCF Services.
openTimeout A xref:System.TimeSpan value that specifies the interval of time provided for an open operation to complete. This value should be greater than or equal to xref:System.TimeSpan.Zero. The default is 00:01:00.
receiveTimeout A xref:System.TimeSpan value that specifies the interval of time provided for a receive operation to complete. This value should be greater than or equal to xref:System.TimeSpan.Zero. The default is 00:01:00.
sendTimeout A xref:System.TimeSpan value that specifies the interval of time provided for a send operation to complete. This value should be greater than or equal to xref:System.TimeSpan.Zero. The default is 00:01:00.

Child Elements

Element Description
<compositeDuplex> Specifies two-way messaging to the custom binding. It is used with transports that do not allow duplex communications natively, for example, HTTP. TCP, by contrast, allows duplex communications natively, and does not require the use of this binding element for the service to send messages back to a client.

The client must expose an address for the service to make contact and establish a connection. This client address is provided by the ClientBaseAddress attribute.

This element is of type xref:System.ServiceModel.Configuration.CompositeDuplexElement.
<pnrpPeerResolver> Specifies a Peer Name Resolution Protocol (PNRP) peer name resolver. This element is of type xref:System.ServiceModel.Configuration.PnrpPeerResolverElement.
<reliableSession> Specifies the setting for WS-Reliable Messaging. When this element is added to a custom binding, the resulting channel can support exactly-once delivery assurances. This element is of type xref:System.ServiceModel.Configuration.ReliableSessionElement.
<security> Specifies the options for security of the custom binding. This element is of type xref:System.ServiceModel.Configuration.SecurityElement.
<sslStreamSecurity> Specifies the security settings for a SSL stream binding. This element is of type xref:System.ServiceModel.Configuration.SslStreamSecurityElement.
<transactionFlow> Specifies that the binding supports transaction flow, and the protocol to be used by the transactionProtocol attribute. This element is of type xref:System.ServiceModel.Configuration.TransactionFlowElement.
<windowsStreamSecurity> Specifies the options for streaming security of the custom binding. This element is of type xref:System.ServiceModel.Configuration.WindowsStreamSecurityElement.

Parent Elements

Element Description
bindings Contains all bindings for Windows Communication Foundation applications.

Remarks

Custom bindings provide full control over the WCF messaging stack. Special tailored bindings can be created my adding the configuration elements for specific entities. For example, the user can combine the httpsTransport section, reliableSession section and the security section to create a reliable and secure https based binding.

An individual binding defines the message stack by specifying the configuration elements for the stack elements in the order they appear on the stack. Each element defines and configures the one element of the stack. There must be one and only one transport element in each custom binding. Without this element, the messaging stack is incomplete.

The order in which elements appear in the stack matters, because it is the order in which operations are applied to the message. The recommended order of stack elements is the following:

  1. Transactions (optional)

  2. Reliable Messaging (optional)

  3. Security (optional)

  4. Transport

  5. Encoder (optional)

Use a custom binding when one of the system-provided bindings does not meet the requirements of your service. A custom binding could be used, for example, to enable the use of a new transport or a new encoder at a service endpoint.

A custom binding is constructed using one of the xref:System.ServiceModel.Channels.CustomBinding.%23ctor%2A from a collection of binding elements that are "stacked" in a specific order:

  • At the top is an optional xref:System.ServiceModel.Channels.TransactionFlowBindingElement that allows flowing transactions.

  • Next is an optional xref:System.ServiceModel.Channels.ReliableSessionBindingElement that provides a session and ordering mechanism as defined in the WS-ReliableMessaging specification. This notion of a session can cross SOAP and transport intermediaries.

  • Next is an optional security binding element that provides security features like authorization, authentication, protection, and confidentiality. The following security binding elements are provided by Windows Communication Foundation (WCF):

    • xref:System.ServiceModel.Channels.SecurityBindingElement

    • xref:System.ServiceModel.Channels.AsymmetricSecurityBindingElement

    • xref:System.ServiceModel.Channels.SymmetricSecurityBindingElement

    • xref:System.ServiceModel.Channels.TransportSecurityBindingElement

  • Next are the optional message-patterns specified by binding elements:

  • xref:System.ServiceModel.Channels.CompositeDuplexBindingElement

  • Next are the optional transport upgrades/helpers binding elements:

    • xref:System.ServiceModel.Channels.PnrpPeerResolverBindingElement

    • xref:System.ServiceModel.Channels.SslStreamSecurityBindingElement

    • xref:System.ServiceModel.Channels.WindowsStreamSecurityBindingElement

  • Next is a required message encoding binding element. You can use your own transport or use one of the following message encoding bindings:

    • xref:System.ServiceModel.Channels.TextMessageEncodingBindingElement

    • xref:System.ServiceModel.Channels.BinaryMessageEncodingBindingElement

    • xref:System.ServiceModel.Channels.MtomMessageEncodingBindingElement

  • At the bottom is a required transport element. You can use your own transport or use one of transport binding elements provided by Windows Communication Foundation (WCF):

    • xref:System.ServiceModel.Channels.TcpTransportBindingElement

    • xref:System.ServiceModel.Channels.NamedPipeTransportBindingElement

    • xref:System.ServiceModel.Channels.HttpTransportBindingElement

    • xref:System.ServiceModel.Channels.HttpsTransportBindingElement

    • xref:System.ServiceModel.Channels.MsmqTransportBindingElement

    • xref:System.ServiceModel.MsmqIntegration.MsmqIntegrationBindingElement

    • xref:System.ServiceModel.Channels.PeerTransportBindingElement

The following table summarizes the options for each layer.

Layer Options Required
Transaction Flow xref:System.ServiceModel.Channels.TransactionFlowBindingElement No
Reliability xref:System.ServiceModel.Channels.ReliableSessionBindingElement No
Security Symmetric, Asymmetric, Transport-Level No
Shape Change xref:System.ServiceModel.Channels.CompositeDuplexBindingElement No
Transport Upgrades SSL stream, Windows stream, Peer Resolver No
Encoding Text, Binary, MTOM, Custom Yes
Transport TCP, Named Pipes, HTTP, HTTPS, flavors of MSMQ, Custom Yes

In addition, you can define your own binding elements and insert them between any of the preceding defined layers.

For a discussion on how to use a custom binding to modify a system-provided binding, see How to: Customize a System-Provided Binding.

See also