2010-11-18 9 views
0

実行時にbasicHttpBindingのコンフィグレーションで通常指定されている転送セキュリティを設定する方法はありますか?IEndpointBehaviorを実装することは可能でしょうか?代わりにIEndpointBehaviorを使用してWCFバインディングでトランスポートセキュリティを設定しますか?

<binding name="DfsAgentService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="1000000" maxBufferPoolSize="10000000" maxReceivedMessageSize="1000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> 
       <security mode="None"/><!--Transport--> 
      </binding> 

そして、この(または何か他のもの)を使用します:

基本的にこれを取る

namespace Endpoints { 
    class DfsEndpoint : IEndpointBehavior{ 


     #region IEndpointBehavior Members 

     void IEndpointBehavior.AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters) { 
      throw new NotImplementedException(); 
     } 

     void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) { 
      throw new NotImplementedException(); 
     } 

     void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) { 
      throw new NotImplementedException(); 
     } 

     void IEndpointBehavior.Validate(ServiceEndpoint endpoint) { 
      throw new NotImplementedException(); 
     } 

     #endregion 
    } 
} 

は、セキュリティモードを変更することが可能ですか?

答えて

0

エンドポイントの動作によってこれを行うことはできません。ビヘイビアではバインディング設定を早期に修正することはできません。

どのようにしても、コードを別の方法で行うことができます。 BasicHttpBindingは、セキュリティモードを指定することができますコンストラクタのオーバーロードがあります。

BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); 

これは、サービスが開始される前に行われなければならない、とあなたがのServiceHostとエンドポイントを自分で作成している前提としています。

+0

ええ、私の問題は、私がバインディングの作成を制御できるとは思わないということです。私はIList の引数を取る第三者のライブラリを使用していますが、そうでなければバインディング情報を指定することはできません。 –

+0

私はあなたの提案に似た何かをしてしまい、バインディングの作成を傍受しました。これは、第三者設定を実際に使用することができないことを意味しましたが、それは問題ありません。 –

関連する問題