<customBinding>

ユーザーのメッセージ スタックを完全に制御できます。

configuration
  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>
    <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 (Peer Name Resolution Protocol) ピア名リゾルバーを指定します。 この要素は PnrpPeerResolverElement 型です。
<reliableSession> WS-ReliableMessaging の設定を指定します。 この要素がカスタム バインディングに追加される場合、その結果となるチャネルにより、正確に 1 回の配信保証をサポートできます。 この要素は ReliableSessionElement 型です。
<security> カスタム バインドのセキュリティ オプションを指定します。 この要素は SecurityElement 型です。
<sslStreamSecurity> SSL ストリーム バインディングのセキュリティ設定を指定します。 この要素は SslStreamSecurityElement 型です。
<transactionFlow> バインディングがトランザクション フローをサポートし、プロトコルが transactionProtocol 属性によって使用される必要があることを指定します。 この要素は TransactionFlowElement 型です。
<windowsStreamSecurity> カスタム バインドのストリーミング セキュリティのオプションを指定します。 この要素は WindowsStreamSecurityElement 型です。

親要素

要素 説明
バインディング Windows Communication Foundation アプリケーションのすべてのバインディングを含みます。

解説

カスタム バインディングを使用すると、WCF メッセージ スタックのフル コントロールが可能になります。 特定のエンティティの構成要素を追加した、特別にカスタマイズされたバインディングを作成できます。 たとえば、ユーザーは httpsTransport セクション、reliableSession セクション、および security セクションを組み合わせて、信頼できるセキュリティで保護された HTTPS ベースのバインディングを作成できます。

個別のバインディングは、メッセージ スタックを、スタック要素の構成要素をスタックに出現する順序で指定することにより定義します。 各要素は、スタック内の 1 つの要素を定義および構成します。 各カスタム バインディング内のトランスポート要素は 1 つだけにする必要があります。 この要素がない場合、メッセージ スタックは不完全です。

要素がスタックに出現する順序は重要です。それは、その順序で操作がメッセージに適用されるためです。 スタック要素で推奨される順序を次に示します。

  1. トランザクション (省略可能)

  2. リライアブル メッセージ機能 (省略可能)

  3. セキュリティ (省略可能)

  4. トランスポート

  5. エンコーダー (省略可能)

システムが提供するバインディングの中にサービスの要件を満たすものがない場合は、カスタム バインドを使用します。 たとえば、カスタム バインドを使用すると、サービス エンドポイントで新しいトランスポートや新しいエンコーダーを使用できます。

カスタム バインドは、特定の順序で "積み重ねられている" バインド要素のコレクションから CustomBinding の 1 つを使用して作成します。

各層のオプションの概要を次の表に示します。

レイヤー Options 必須
トランザクション フロー TransactionFlowBindingElement いいえ
[信頼性] ReliableSessionBindingElement いいえ
セキュリティ 同期、非同期、トランスポート レベル いいえ
形状の変更 CompositeDuplexBindingElement いいえ
トランスポートのアップグレード SSL ストリーム、Windows ストリーム、ピア リゾルバー いいえ
エンコード テキスト、バイナリ、MTOM、カスタム はい
トランスポート TCP、名前付きパイプ、HTTP、HTTPS、MSMQ のフレーバー、カスタム はい

さらに、独自のバインド要素を定義し、それを定義済みの層のいずれかの間に挿入できます。

カスタム バインディングを使用し、システム提供のバインディングを変更する方法については、「方法: システム指定のバインディングをカスタマイズする」を参照してください。

関連項目