2010-11-30 59 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 }); 
    } 
}