0

有没有办法在运行时设置通常在 basicHttpBinding 的配置中指定的传输安全性,可能通过实现 IEndpointBehavior?

基本上采取这个:

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

是否可以更改安全模式?

4

1 回答 1

0

我认为不可能通过端点行为来做到这一点。行为不能足够早地修改绑定配置。

但是,它可以以不同的方式在代码中完成。BasicHttpBinding 有一个构造函数重载,它允许指定安全模式:

BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

这必须在服务启动之前完成,并假设您正在自己创建 ServiceHost 和 Endpoints。

于 2010-11-19T15:43:52.330 回答