WCF wsHttpBinding + Windows身份验证通过SSL失败

时间:2011-12-05 21:50:53

标签: .net wcf web-config ninject config

如果没有SSL,此服务没有问题,但在使用SSL时失败了。我将假设这是一个配置错误并发布相关的配置文件

失败是什么意思?我从IIS获得以下不那么有用的消息:

The requested service, 'https://.../IssueTrackerService.svc' could not be activated.
See the server's diagnostic trace logs for more information.

来自跟踪日志的此消息:

Failed to open Ninject.Extensions.Wcf.NinjectServiceHost
Faulted Ninject.Extensions.Wcf.NinjectServiceHost
ServiceHost faulted.

这里的任何源代码绝对没有改变。唯一的区别是我正在尝试将其配置为在SSL上运行。所以只修改了web.configs。

主机web.config:

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="NGIT_ConnectionString"
         connectionString="..." />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WsSecured">
          <security mode="Transport">
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="...IssueTrackerService"
               behaviorConfiguration="mexEnabled">
        <endpoint name="IIssueTrackerService"
                  address=""
                  binding="wsHttpBinding"
                  bindingConfiguration="WsSecured"
                  contract="....IIssueTrackerService" />
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="mexEnabled">
          <serviceMetadata httpsGetEnabled="true"
                           httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
      <source name="myUserTraceSource"
              switchValue="Information, ActivityTracing">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="xml"
           type="System.Diagnostics.XmlWriterTraceListener"
           initializeData="Error.svclog" />
    </sharedListeners>
  </system.diagnostics>
  <system.webServer>
    <directoryBrowse enabled="false" />
  </system.webServer>
</configuration>

客户端web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WsSecured">
          <security mode="Transport">
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint name="IIssueTrackerService"
                address="https://.../IssueTrackerService.svc"
                binding="wsHttpBinding"
                bindingConfiguration="WsSecured"
                contract="....IIssueTrackerService" />
    </client>
  </system.serviceModel>
    <system.webServer>
        <security>
            <authentication>
                <windowsAuthentication enabled="true" />
            </authentication>
        </security>
    </system.webServer>
</configuration>

为了更好地衡量,我将文件包含在服务主机应用程序中:

IssueTracker.svc

<%@
    ServiceHost
    Factory="Ninject.Extensions.Wcf.NinjectServiceHostFactory"
    Service="....IssueTrackerService"
%>

Global.asax中

using Ninject;
using Ninject.Extensions.Wcf;

namespace ....NGITWcf.Host
{
    public class Global : NinjectWcfApplication
    {
        protected override IKernel CreateKernel()
        {
            return new StandardKernel(new ServiceModule());
        }
    }
}

ServiceModule.cs

using Ninject.Modules;
using Ninject.Extensions.Wcf;
using ...;

namespace ....NGITWcf.Host
{
    internal class ServiceModule : NinjectModule
    {
        public override void Load()
        {
            this.Bind<IUserIssueRepository>()
                .To<SqlUserIssueRepository>();
        }
    }
}

0 个答案:

没有答案