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 theChannelFactory<T>
you had in your example, but you'll need to pass an extra parameter (typedInstanceContext
) which will contain an implementation of the callback interface used to receive the messages from the server.