문제

There's lots of material explaining why using svcutil.exe (or 'add service reference') is bad - lack of testability, tight coupling etc. Manually creating a client proxy for a simple service is straightforward, you just need to manually create your interface and create a channel:

IMessageServiceAsync service = new ChannelFactory<IMessageServiceAsync>("BasicHttpBinding_IMessageEndpoint").CreateChannel(); 

I want to do something similar but for a Silverlight PollingDuplex client.

This appears more difficult - the generated client inherits from System.ServiceModel.DuplexClientBase - I assume my manually created client would also need to? Or is there a way to hookup all the client-side Duplex callback functionality without implementing this base class?

Has anyone ever tried this? Is it even possible?

도움이 되었습니까?

해결책

It is possible - you can use the DuplexChannelFactory<T> class to create a proxy in a similar way as the ChannelFactory<T> you had in your example, but you'll need to pass an extra parameter (typed InstanceContext) which will contain an implementation of the callback interface used to receive the messages from the server.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top