Manual implementation of WCF Duplex Proxy
-
Hey there! I'm trying to manually create a duplex proxy class for a WCF client/server application. Unfortunately there is no info about it on the net :( Has anyone ever tried it and if can you post a nice and clean solution? I have separated my contract, service implementation, host, proxy and client application in separate assemblies. And now it looks like I will need to duplicate the contract interfaces at the client proxy in order to have async invocation of the methods. Please help!
-
Hey there! I'm trying to manually create a duplex proxy class for a WCF client/server application. Unfortunately there is no info about it on the net :( Has anyone ever tried it and if can you post a nice and clean solution? I have separated my contract, service implementation, host, proxy and client application in separate assemblies. And now it looks like I will need to duplicate the contract interfaces at the client proxy in order to have async invocation of the methods. Please help!
well this is possible to do. in our upcoming solution we just do it. unfortunately I connot post all the code, is too much tight in our custom solution, but a little peace of the essential Helper: SharedProxyBaseDuplex<T,C> ContractDescription contractDesript = ContractDescription.GetContract(EContract.IDuplexRouterService.FullType); ServiceEndpoint serviceEndpoint = new ServiceEndpoint(contractDesript, binding, endpointAddress); lock (_channelLock) { CallbackObject = callbackObject == null ? new C() : (C)callbackObject; InnerFactory = new DuplexChannelFactory<T>(new InstanceContext(null, CallbackObject), serviceEndpoint); } I recommend you to invest 5 days an go to see a WCF Master Class by iDesign, is really getting you closer to the subject. Cheers, Christoph
-
well this is possible to do. in our upcoming solution we just do it. unfortunately I connot post all the code, is too much tight in our custom solution, but a little peace of the essential Helper: SharedProxyBaseDuplex<T,C> ContractDescription contractDesript = ContractDescription.GetContract(EContract.IDuplexRouterService.FullType); ServiceEndpoint serviceEndpoint = new ServiceEndpoint(contractDesript, binding, endpointAddress); lock (_channelLock) { CallbackObject = callbackObject == null ? new C() : (C)callbackObject; InnerFactory = new DuplexChannelFactory<T>(new InstanceContext(null, CallbackObject), serviceEndpoint); } I recommend you to invest 5 days an go to see a WCF Master Class by iDesign, is really getting you closer to the subject. Cheers, Christoph
Thanks a lot for the reply! I have actually made my way using a sample code generated by VS for a duplex proxy. Then I realized that my problem is not the duplex part, but the async invocation of the methods and the async client side contract. Anyway I solved the issue. Your approach with generic proxy looks very nice :) Thanks for sharing! Cheers, Vik