I have a set of interfaces that I'd like to register as WCF clients in Windsor and have them all use WCF discovery to find endpoints. I was hoping to do something as simple as this:
[TestMethod]
public void TestMethod1()
{
var container = new WindsorContainer();
container.AddFacility<WcfFacility>();
container.Register(Component.For<IWcfClientModel>().ImplementedBy<WcfDiscoveryClientModel>());
// NOTE: ISampleService wasn't installed on purpose
// to force the container to generate a WCF proxy
var x = container.Resolve<ISampleService>();
Assert.IsNotNull(x);
}
Where WcfDiscoveryClientModel is defined like this:
public class WcfDiscoveryClientModel : WcfClientModelBase
{
public WcfDiscoveryClientModel()
{
Endpoint = WcfEndpoint.Discover();
}
}
But of course, no code in WcfDiscoveryClientModel
is ever executed. From looking at the facility source, it looks like it'll only ever use DefaultClientModel
unless I pass something into the arguments to Resolve()
. I'm not entirely certain what I'd pass in as arguments, but I'd really like to avoid that route since these clients will be used in a web app.
So, my question is: what is the best way to override the default client model selection?
I think you might be on the wrong path, assuming that your service is setup to be discoverable all you need to do is tell your client endpoint to discover the service. Here is an example: