Share via


<customBinding>

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

結構描述階層

<system.serviceModel>
  <bindings>
    <customBinding>

語法

<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 
   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=" SymmeticKey/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 開始,繫結和行為都不需要有名稱。 如需預設組態和無名稱繫結與行為的詳細資訊,請參閱Simplified ConfigurationSimplified Configuration for WCF Services

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

<reliableSession>

指定 WS-Reliable 訊息設定。 將這個項目新增至自訂繫結時,產生的通道可支援確實傳送一次保證。 此項目的型別為 ReliableSessionElement

<customBinding> 的 <security>

指定自訂繫結的安全性選項。 此項目的型別為 SecurityElement

<sslStreamSecurity>

指定 SSL 資料流繫結的安全性設定。 此項目的型別為 SslStreamSecurityElement

<transactionFlow>

指定繫結應支援交易流程,並指定 transactionProtocol 屬性使用的通訊協定。 此項目的型別為 TransactionFlowElement

<windowsStreamSecurity>

指定自訂繫結的資料流 (Streaming) 安全性選項。 此項目的型別為 WindowsStreamSecurityElement

父項目

項目 描述

bindings

包含 Windows Communication Foundation 應用程式的所有繫結。

備註

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

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

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

  1. 交易 (選擇性)

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

  3. 安全性 (選擇性)

  4. 傳輸

  5. 編碼器 (選擇性)

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

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

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

選項 必要項

交易流程

TransactionFlowBindingElement

可靠性

ReliableSessionBindingElement

安全性

對稱、不對稱、傳輸層級

形狀變更

CompositeDuplexBindingElement

傳輸升級

SSL 資料流、Windows 資料流、對等解析程式

編碼

文字、二進位、MTOM、自訂

傳輸

TCP、具名管道、HTTP、HTTPS、MSMQ 的類別、自訂

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

如需有關如何使用自訂繫結來修改系統提供之繫結的討論內容,請參閱 How To: Customize a System-Provided Binding

1.

另請參閱

參考

<customBinding>
Binding
BindingElement
BindingsSection
CustomBinding

概念

<binding>

其他資源

Windows Communication Foundation Bindings
Extending Bindings
Custom Bindings
Windows Communication Foundation Bindings
Configuring System-Provided Bindings
Using Bindings to Configure Services and Clients