I tried to minimize code entry for the WCF CRUD part of a large project using generics and a WCF lock object.
I have a WCF service contract:
[ServiceContract] public interface IResourceService : ICRUDService<DTOResource> { [OperationContract] DTOResource Get(long id); }
and generic interface
public interface ICRUDService<T> where T is IDTO { T Get(long id); }
also a common MVC controller (1 controller for all basic crud for dtos and services)
public class CRUDController<T> : Controller where T is IDTO { readonly ICRUDService<T> service; public CRUDController(ICRUDService<T> service) { this.service = service; } }
On the client side, I register the WCF client in the Windsor Container
Component .For<IResourceService , ICRUDService<DTOResource>>() .AsWcfClient(... standard stuff... )
Everythig works fine, components and services are registered, the controller is created correctly, services
readonly ICRUDService<T> service;
in the controller is of type
Castle.Proxies.IResourceService
But when I try to use the service in the controller, I have an error
Method Get is not supported on this proxy, this can happen if the method is not marked with OperationContractAttribute or if the interface type is not marked with ServiceContractAttribute.
When in the controller I hardcode cast
((IResourceService)service).Get(id);
everything is working fine, so I believe this problem is solvable.
I also tried using Forward (with the same result):
Component .For<IActionTypeService> .Forward<ICRUDService<DTOResource>>().AsWcfClient(...
How to make it work?