2014-10-21 3 views
4

최근에 Castle Windsor 로의 이전이 시작되었으며 WCF 서비스를 실행하는 데 몇 가지 문제가 있습니다. 일반 창문 서비스 에 머무르지 않고 SSL 자료를 제공하고 고객이 제시 한 인증서를 확인하기 위해 X509CertificateValidator 사용자 지정을 사용합니다.WCF & Castle Windsor - 잊어 버린 것 같습니다.

다음은 WCF 서비스를 만드는 데 사용하는 코드입니다. WCF 서비스를 참조하는 별도의 프로젝트에 있습니다.

public IWindsorContainer RegisterService<T,K>(
      IServiceBehavior customBehavior, 
      Action<ServiceHost> onCreate = null, 
      Action<ServiceHost> onOpen = null, 
      Action<ServiceHost> onClose = null, 
      Action<ServiceHost> onFault = null) where T : class where K : T 
     { 

      var facility = this.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero); 

      var serviceModel = new DefaultServiceModel() 
       .OnCreated(onCreate) 
       .OnOpened(onOpen) 
       .OnClosed(onClose) 
       .OnFaulted(onFault); 

      var service = Component.For<T>() 
        .ImplementedBy<K>() 
        .AsWcfService<T>(serviceModel) 
        .LifestylePerWcfOperation<T>(); 

      if (customBehavior != null) 
       facility.Register(Component.For<IServiceBehavior>().Instance(customBehavior)); 

      facility.Register(service); 

      return facility; 

     } 

이 서비스는 예상대로 (내가 문제없이 크롬을 사용하여 서비스로 이동할 수 있습니다) 시작하고 서비스를 제시하고 SSL 물질을 확인하는 (즉, 사용자 정의 유효성 검사기 안타)하지만 그 후, 클라이언트가이를 얻을 수있다 FaultException A의 :

... 
<system.web> 
    <httpModules> 
     <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" /> 
    </httpModules> 
    <membership defaultProvider="ClientAuthenticationMembershipProvider"> 
     <providers> 
     <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" /> 
     </providers> 
    </membership> 
    <roleManager defaultProvider="ClientRoleProvider" enabled="true"> 
     <providers> 
     <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" /> 
     </providers> 
    </roleManager> 
    </system.web> 
    <system.webServer> 
    <modules> 
     <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" /> 
    </modules> 
    <handlers> 
     <add name="PerRequestLifestyle" verb="*" path="*.castle" preCondition="managedHandler" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Microkernel"/> 
    </handlers> 
    </system.webServer> 
    <system.serviceModel> 
    <extensions> 
     <endpointExtensions> 
     <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" /> 
     </endpointExtensions> 
     <bindingExtensions> 
     <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" /> 
     </bindingExtensions> 
     <behaviorExtensions> 
     <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" /> 
     </behaviorExtensions> 
     <bindingElementExtensions> 
     <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" /> 
     </bindingElementExtensions> 
    </extensions> 
... 
: 아래
Looks like you forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule 
To fix this add 
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" /> 
to the <httpModules> section on your web.config. 
If you plan running on IIS in Integrated Pipeline mode, you also need to add the module to the <modules> section under <system.webServer>. 
Alternatively make sure you have Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 assembly in your GAC (it is installed by ASP.NET MVC3 or WebMatrix) and Windsor will be able to register the module automatically without having to add anything to the config file. 

App.Config의 덩어리입니다, 내가 구글을 통해 몇 가지 추측을 통해 제안 된 모든 영역에서 모듈을 배치하는 것을 시도했다

Im 꽤 많은 아이디어가 있습니다. 누구든지 원인이 무엇인지 알 수 있습니까? 그렇지 않다면 누구든지 내가 받고있는 오류에 대해 더 자세히 설명 할 수 있을까요? 도움이 될 것입니다. 다시 한번 내가 내 자신의 질문 (게시 후 다음 날, 오 사랑)에 응답하고있어

답변

6

: P를

이 오류 메시지는 (오픈 소스에 대한 신에게 감사!) 여기에서 발생되는

:

https://github.com/castleproject/Windsor/blob/016730de012f15985410fb33e2eb907690fe5a28/src/Castle.Windsor/MicroKernel/Lifestyle/PerWebRequestLifestyleModule.cs

tldr - 아래 참조 :이에서

public class PerWebRequestLifestyleModule : IHttpModule 
{ 
    ... 
    private static void EnsureInitialized() 
     { 
      if (initialized) 
      { 
       return; 
      } 
      var message = new StringBuilder(); 
      message.AppendLine("Looks like you forgot to register the http module " + typeof(PerWebRequestLifestyleModule).FullName); 
      message.AppendLine("To fix this add"); 
      message.AppendLine("<add name=\"PerRequestLifestyle\" type=\"Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor\" />"); 
      message.AppendLine("to the <httpModules> section on your web.config."); 
      if (HttpRuntime.UsingIntegratedPipeline) 
      { 
       message.AppendLine(
        "Windsor also detected you're running IIS in Integrated Pipeline mode. This means that you also need to add the module to the <modules> section under <system.webServer>."); 
      } 
      else 
      { 
       message.AppendLine(
        "If you plan running on IIS in Integrated Pipeline mode, you also need to add the module to the <modules> section under <system.webServer>."); 
      } 
#if !DOTNET35 
      message.AppendLine("Alternatively make sure you have " + PerWebRequestLifestyleModuleRegistration.MicrosoftWebInfrastructureDll + 
           " assembly in your GAC (it is installed by ASP.NET MVC3 or WebMatrix) and Windsor will be able to register the module automatically without having to add anything to the config file."); 
#endif 
      throw new ComponentResolutionException(message.ToString()); 
     } 
    ... 
} 

을 나는 빨리이 문제가 PerWebRequestLifestyleModule이없는 것을 것을 수집 초기화되었는데, 나는이 서비스를 위해 그것을 필요로하지 않았기 때문에 나에게 좋았다!

본인의 코드를 더 살펴보면,이 서비스를 위해로드 된 일부 저장소는 웹 콘솔 인 빙고에서 사용되었을 때 LifestylePerWebRequest을 사용하도록 설정되었습니다!

다른 것으로 조정 한 후 (이 경우 'LifestylePerWcfOperation`) 모두 정상적으로 작동합니다.