我有一个MVC应用程序,我使用Spring.NET将我的WCF服务注入Controller。以下是我的配置
MVC客户端Web.Config
<wcf:channelFactory id="LoginService" channelType="App.Interfaces.Services.ILoginService, AppServiceInterfaces" endpointConfigurationName="EndPointLoginService"/>
<endpoint name="EndPointLoginService" address="http://localhost:xxx/LoginService.svc" contract="App.Interfaces.Services.ILoginService" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding1" behaviorConfiguration="ServiceEndpointBehavior" />
WCF服务Web.Config
<object id="LoginService" type= "App.Services.LoginService, AppLoginService" singleton="false">
</object>
<service name="LoginService" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding1" contract="App.Interfaces.Services.ILoginService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
登录Service.svc
<%@ ServiceHost Language="C#" Debug="true" Service="LoginService" Factory="Spring.ServiceModel.Activation.ServiceHostFactory" %>
以上工作完全没问题。现在我想为上面的
实现性能记录所以我在WCF服务Web.Config中添加了以下内容
<object id="performanceLoggingAroundAdvice" type="AOP.Advice.PerformanceLoggingAroundAdvice, AOP" singleton="false" scope="request"/>
我有一个名为AOP的项目。
和
<object id="LoginService" type= "App.Services.LoginService, AppLoginService" singleton="false">
<property name="InterceptorNames">
<list>
<value>performanceLoggingAroundAdvice</value>
</list>
</property>
但是我收到了一个错误..登录服务的初始化失败了。有人可以帮我配置。
答案 0 :(得分:0)
通过在我的服务层配置
中添加以下内容来解决此问题<object type="Spring.Aop.Framework.AutoProxy.TypeNameAutoProxyCreator, Spring.Aop">
<property name="TypeNames">
<list>
<value>App.Services.LoginService</value>
</list>
</property>
<property name="InterceptorNames">
<list>
<value>performanceLoggingAroundAdvice</value>
</list>
</property>
</object>
并删除了现有的Interceptornames属性配置
<property name="InterceptorNames">
<list>
<value>performanceLoggingAroundAdvice</value>
</list>
</property>
这
<object id="LoginService" type= "App.Services.LoginService, AppLoginService"
singleton="false">
<property name="InterceptorNames">
<list>
<value>performanceLoggingAroundAdvice</value>
</list>
</property>
</objects>