Intercepting a WCF Service with Autofac

别等时光非礼了梦想. 提交于 2019-12-13 04:05:45

问题


I am attempting to intercept methods on a WCF service server side with the following registration:

containerBuilder.RegisterType<Service>().As<IServiceContract>().InstancePerLifetimeScope()
                .EnableInterfaceInterceptors().InterceptedBy(typeof(MethodInterceptor));

however, when I do the service endpoint disappears. The WCF service is hosted inside a Windows Service. Any ideas?

The exception I receive is as follows:

System.ServiceModel.EndpointNotFoundException: There was no endpoint listening athttp://localhost:8000/endpointaddressthat could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.

The MethodInterceptor is registered as follows:

containerBuilder.Register(componentContext => new MethodInterceptor(invocation =>
{
    return new NLogToLoggerAdaptor(LogManager.GetLogger(invocation.InvocationTarget.GetType().FullName));
})).InstancePerLifetimeScope();

来源:https://stackoverflow.com/questions/19297234/intercepting-a-wcf-service-with-autofac

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!