Reputation: 3754
i have a client & server application which communicate using WCF. To add some custom session information to each WCF message header i wrapped the client WCF channel into a "ClientChannelProxy" class and used the Unity Interception extension to add my custom header information using aspects.
IUnityContainer container = new UnityContainer();
container.AddNewExtension<Interception>();
container.RegisterType<IClientService, ClientServiceProxy>();
container.Configure<Interception>().SetInterceptorFor<IClientService>(new
TransparentProxyInterceptor());
This works fine for the client since i can easly configure the unity container and interception using the code shown above.
But how to setup unity and interception on the server side? My WCF service is configured in a .SVC file, i don't have any possiblity to configure interception and getting my aspects executed.
<%@ ServiceHost Language="C#" Debug="true" Service="Test.ClientService" %>
<!-- How to configure Unity Interception for this WCF-Service ? -->
Would ne nice if anyone could help me getting it working. Thanks!
Upvotes: 5
Views: 2393
Reputation: 15571
You need to create an inspector/interceptor on the server side. You may refer to this post: WCF Parameter Validation with Interceptor and http://msdn.microsoft.com/en-us/library/ms751495.aspx
Upvotes: 2
Reputation: 16013
You could enable your WCF service with DI on implementing your own InstanceProvider, ServiceHost, etc. with Unity. So you'll be able to plug your aspect.
Here's an exemple of how it could be achieved : http://initializecomponent.blogspot.com/2008/06/integrating-unity-with-wcf.html
Upvotes: 2