2010-11-30 113 views
1

配置WCF服务如何配置负载平衡器和特定端点如何为负载平衡器

+0

您是否在执行“正常”负载平衡(即只是将请求转发到不同的服务器),还是您正在使用负载平衡器进行SSL卸载? – 2010-11-30 08:06:11

回答

1

你可以尝试写一个custom service host factory将使用负载平衡器的URL作为基址的WCF服务:

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 }); 
    } 
}