Share via


<netNamedPipeBinding>

コンピュータ上のプロセス間通信に適した、セキュリティで保護された信頼できる最適バインディングを定義します。既定では、信頼のための WS-ReliableMessaging、転送セキュリティ用トランスポート セキュリティ、メッセージ配信用名前付きパイプ、およびバイナリ メッセージ エンコーディングを持つランタイム通信スタックを生成します。

<system.serviceModel>
  <bindings>
    <netNamedPipeBinding>

<netNamedPipeBinding>
   <binding 
      closeTimeout="TimeSpan"
      hostNameComparisonMode="StrongWildCard/Exact/WeakWildcard"
      maxBufferPoolSize="Integer"
      maxBufferSize="Integer"
      maxConnections="Integer" 
      maxReceivedMessageSize="Integer"
            name="string"
      openTimeout="TimeSpan" 
      receiveTimeout="TimeSpan"
      sendTimeout="TimeSpan"
      transactionFlow="Boolean"
      transactionProtocol="OleTransactions/WS-AtomicTransactionOctober2004"
            transferMode="Buffered/Streamed/StreamedRequest/StreamedResponse"
      <security mode="None/Transport">
            <transport clientCredentialType="None/Windows"
                protectionLevel="None/Sign/EncryptAndSign" />
      </security>
      <readerQuotas maxDepth="integer" 
            maxStringContentLength="integer"
            maxByteArrayContentLength="integer"
            maxBytesPerRead="integer"
            maxNameTableCharCount="integer" />
   </binding>
</netNamedPipeBinding>

属性および要素

属性

属性 説明

closeTimeout

クローズ操作が完了するまでの期間を指定する TimeSpan 値。この値は必ず Zero 以上である必要があります。既定値は 00:01:00 です。

hostnameComparisonMode

URI の解析に使用する HTTP ホスト名比較モードを指定します。この属性は HostnameComparisonMode 型で、URI が一致したときにサービスへのアクセスにホスト名を使用するかどうかを指定します。既定値は StrongWildcard で、一致しているホスト名を無視します。

maxBufferPoolSize

このバインディングに使用するバッファ プール サイズの上限を指定する整数。既定は 524,288 バイト (512 * 1024) です。Windows Communication Foundation (WCF) では、多くの部分でバッファを使用します。使用するたびに毎回バッファを作成および破壊すると負荷が高くなります。バッファのガベージ コレクションも同様です。バッファ プールを使用すると、バッファをプールから取得して使用し、作業が終わったらプールに戻すことができます。これで、バッファの作成と破壊のオーバーヘッドを回避できます。

maxBufferSize

メッセージをメモリに保存するのに使用するバッファの最大サイズをバイト単位で指定する正の整数。バッファがいっぱいになると、入りきらなかったデータは、バッファに空きが出るまで、基になるソケットに留まります。この値が maxReceivedMessageSize 属性の値を下回らないようにしてください。既定は 65536 です。詳細については、MaxBufferSize を参照してください。

maxConnections

サービスが作成し受け付ける発信/着信接続数の上限を指定する整数。この属性により指定された別個の制限に対して、着信接続および発信接続がカウントされます。

制限を超える着信接続は、制限内に空きができるまでキューに置かれます。

制限を超える発信接続は、制限内に空きができるまでキューに置かれます。

既定値は 10 です。

maxReceivedMessageSize

チャネルで受信可能な最大メッセージ サイズ (ヘッダーを含む) をバイト単位で指定する正の整数が、このバインディングを使用して設定されました。この制限を超えるメッセージの送信者が、SOAP エラーを受信します。受信者がメッセージをドロップし、トレース ログにそのイベントのエントリを作成します。既定値は 65536 です。

name

バインディングの設定名を格納する文字列です。この値は、バインディングの ID として使用されるため、一意にする必要があります。

openTimeout

実行中の操作が完了するまでの時間間隔を指定する TimeSpan 値です。この値は必ず Zero 以上である必要があります。既定値は 00:01:00 です。

receiveTimeout

受信操作が完了するまでの時間間隔を指定する TimeSpan 値です。この値は必ず Zero 以上である必要があります。既定値は 00:10:00 です。

sendTimeout

送信操作が完了するまでの時間間隔を指定する TimeSpan 値です。この値は必ず Zero 以上である必要があります。既定値は 00:01:00 です。

transactionFlow

バインディングが WS-Transactions のフローをサポートするかどうかを指定するブール値です。既定値は false です。

transactionProtocol

このバインディングで使用されるトランザクション プロトコルを指定します。有効な値は、以下のとおりです。

  • OleTransactions
  • WS-AtomicTransactionOctober2004

既定値は OleTransactions です。この属性は TransactionProtocol 型です。

transferMode

メッセージが要求や応答をバッファするか、ストリーミングするかを指定する TransferMode 値です。

子要素

要素 説明

<netNamedPipeBinding> の <security>

バインディングのセキュリティ設定を定義します。この要素は NetNamedPipeBindingElement 型です。

<readerQuotas>

このバインディングを使用して設定されるエンドポイントにより処理可能な、SOAP メッセージの複雑さに対する制約を定義します。この要素は XmlDictionaryReaderQuotasElement 型です。

親要素

要素 説明

<bindings>

この要素には、標準バインディングおよびカスタム バインディングのコレクションが保持されます。各エントリは、それぞれの name によって識別されます。サービスは、name を使用してバインディングをリンクすることにより、バインディングを使用します。

解説

NetNamedPipeBinding は、トランスポート セキュリティ、メッセージ配信用の名前付きパイプ、およびバイナリ メッセージ エンコーディングを使用する通信スタックを既定で生成します。このバインディングは、コンピュータ間通信に適した、WCF (Windows Communication Foundation) システム標準の選択肢です。トランザクションもサポートします。

NetNamedPipeBinding の既定の構成は、NetTcpBinding によって提供される構成に似ていますが、それよりも単純です。この理由は、WCF の実装はコンピュータ間での使用のみを目的としているので、公開される機能が少ないためです。最も顕著な違いは、securityMode 設定に None オプションと Transport オプションしか用意されていないことです。SOAP セキュリティ サポートは、オプションに含まれません。このセキュリティ動作は、オプションの securityMode 属性で構成できます。

次の例では、同じコンピュータ上でのプロセス間通信を実現する NetNamedPipeBinding バインディングを示します。名前付きパイプは、異なるコンピュータ間では動作しません。

バインディングは、クライアントとサービスの構成ファイルに指定されます。バインディングの種類は、<endpoint> 要素の binding 属性に指定します。netNamedPipeBinding バインディングを構成してその設定の一部を変更する場合は、バインディング構成を定義する必要があります。エンドポイントは、バインディング構成を bindingConfiguration 属性を使用して名前で参照します。この例では、バインディングの構成の名前は Binding1 です。

<configuration>
  <system.serviceModel>
    <services>
      <service name="Microsoft.ServiceModel.Samples.CalculatorService"
               behaviorConfiguration="CalculatorServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="https://localhost:8000/ServiceModelSamples/service"/>
          </baseAddresses>
        </host>
        <!-- this endpoint is exposed at the base address provided by host: net.pipe://localhost/ServiceModelSamples/service  -->
        <endpoint address="net.pipe://localhost/ServiceModelSamples/service"
                  binding="netNamedPipeBinding"
                  bindingConfiguration="Binding1" 
                  contract="Microsoft.ServiceModel.Samples.ICalculator" />
        <!-- the mex endpoint is exposed at https://localhost:8000/ServiceModelSamples/service/mex -->
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>

    <bindings>
      <netNamedPipeBinding>
        <binding name="Binding1" 
                 closeTimeout="00:01:00"
                 openTimeout="00:01:00" 
                 receiveTimeout="00:10:00" 
                 sendTimeout="00:01:00"
                 transactionFlow="false" 
                 transferMode="Buffered" 
                 transactionProtocol="OleTransactions"
                 hostNameComparisonMode="StrongWildcard" 
                 maxBufferPoolSize="524288"
                 maxBufferSize="65536" 
                 maxConnections="10" 
                 maxReceivedMessageSize="65536">
          <security mode="Transport">
            <transport protectionLevel="EncryptAndSign" />
          </security>
        </binding>
      </netNamedPipeBinding>
    </bindings>

    <!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
    <behaviors>
      <serviceBehaviors>
        <behavior name="CalculatorServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

関連項目

リファレンス

NetNamedPipeBindingElement
NetNamedPipeBinding

概念

<binding>

その他の技術情報

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