<customBinding>

對使用者提供訊息堆疊的完整控制權。

<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>

屬性和項目

下列各節說明屬性、子元素和父元素

屬性

屬性 描述
closeTimeout TimeSpan 值,指定提供用來讓關閉作業完成的時間間隔。 這個值應該大於或等於 Zero。 預設為 00:01:00。
NAME 包含繫結之組態名稱的字串。 這個值是使用者定義的字串,它會充當自訂繫結的識別字串。 從 .NET Framework 4 開始,不需要有名稱的系結和行為。 如需預設設定、無名稱繫結與行為的詳細資訊,請參閱簡化的組態 (部分機器翻譯) 與WCF 服務的簡化組態 (部分機器翻譯)。
openTimeout TimeSpan 值,指定提供用來讓開啟作業完成的時間間隔。 這個值應該大於或等於 Zero。 預設為 00:01:00。
receiveTimeout TimeSpan 值,指定接收作業完成其作業之時間間隔。 這個值應該大於或等於 Zero。 預設為 00:01:00。
sendTimeout TimeSpan 值,指定提供用來讓傳送作業完成的時間間隔。 這個值應該大於或等於 Zero。 預設為 00:01:00。

子元素

元素 描述
<compositeDuplex> 指定自訂繫結的雙向傳訊。 它是和本身不允許雙工通訊的傳輸一起使用,例如 HTTP。 相反地,TCP 本身就允許雙工通訊,因此不需要使用這個繫結項目也可讓服務將訊息傳回用戶端。

用戶端必須公開位址,才能讓服務接觸並建立連接。 這個用戶端位址是由 ClientBaseAddress 屬性提供。

此項目的型別為 CompositeDuplexElement
<pnrpPeerResolver> 指定對等名稱解析通訊協定 (PNRP) 對等名稱解析程式。 此項目的型別為 PnrpPeerResolverElement
<&lt;reliableSession&gt;> 指定 WS-Reliable 訊息設定。 將這個項目新增至自訂繫結時,產生的通道可支援確實傳送一次保證。 此項目的型別為 ReliableSessionElement
<security> 指定自訂繫結的安全性選項。 此項目的型別為 SecurityElement
<sslStreamSecurity> 指定 SSL 資料流繫結的安全性設定。 此項目的型別為 SslStreamSecurityElement
<transactionFlow> 指定繫結應支援交易流程,並指定 transactionProtocol 屬性使用的通訊協定。 此項目的型別為 TransactionFlowElement
<windowsStreamSecurity> 指定自訂繫結的資料流 (Streaming) 安全性選項。 此項目的型別為 WindowsStreamSecurityElement

父項目

元素 描述
繫結 包含 Windows Communication Foundation 應用程式的所有繫結。

備註

自訂繫結會提供對於 WCF 訊息堆疊的完整控制權。 您可以新增特定實體的組態項目,來建立特別量身訂作的繫結。 例如,使用者可結合 httpsTransport 區段、reliableSession 區段和 security 區段來建立可靠且安全的 https 繫結。

個別繫結定義訊息堆疊的方式,是依據堆疊項目在堆疊中的出現順序來指定其組態項目。 每個項目都會定義及設定堆疊的一個項目。 各個自訂繫結中一定要出現一個而且是唯一一個的傳輸項目。 如果沒有這個項目,訊息堆疊就不完整。

項目在堆疊中的出現順序很重要,因為這是作業套用至訊息的順序。 建議的堆疊項目順序如下所示:

  1. 交易 (選擇性)

  2. 可信賴傳訊 (選擇性)

  3. 安全性 (選擇性)

  4. 傳輸

  5. 編碼器 (選擇性)

當系統提供的其中一個繫結程序不符合服務的需求時,請使用自訂繫結程序。 例如,若要在服務端點上啟用新的傳輸或新的編碼器,可以使用自訂繫結。

在建構自訂繫結時,會使用依據特定順序堆疊之繫結項目集合中的其中一個 CustomBinding

下表摘要列出每一層的選項。

選項。 必要
異動流程 TransactionFlowBindingElement
可靠性 ReliableSessionBindingElement
安全性 對稱、不對稱、傳輸層級
形狀變更 CompositeDuplexBindingElement
傳輸升級 SSL 資料流、Windows 資料流、對等解析程式
編碼 文字、二進位、MTOM、自訂
傳輸 TCP、具名管道、HTTP、HTTPS、MSMQ 的類別、自訂

此外,您也可以定義自己的繫結項目,並將其插入上述任何定義層之間。

如需如何使用自訂繫結來修改系統所提供繫結的討論,請參閱如何:自訂系統提供的繫結

另請參閱