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!
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With