How to configure a WCF service for a load balancer
How t开发者_开发问答o configure a WCF service for a load balancer and specific the end points
You could try writing a custom service host factory which will use the load balancer's url as base address:
public class CustomServiceHostFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(
Type serviceType, Uri[] baseAddresses)
{
Uri uri = null;
if (baseAddresses.Length < 2)
{
uri = baseAddresses[0];
}
else
{
// TODO: You need to choose the load balancer's url here:
uri = baseAddresses[????];
}
return base.CreateServiceHost(serviceType, new Uri[] { uri });
}
}
精彩评论