Click here to Skip to main content
15,885,151 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a WCF Service(in C#) hosted on multiple IIS servers. And I have a REST API(C#) accessing these service. I want that if WCF service on server1 failed to respond(or temporary down) then Rest API makes call to server2 for the same function and get data. if server2 also fails then check for server3 and so on...

I don't want to use GetMetaData for this. Please help me out of this problem.

Thanks very much.!
Posted

1 solution

check the following code


static IEnumerable<uri> GetServiceUris()
{
yield return new Uri("SERVICE1");
yield return new Uri("SERVICE2");
yield return new Uri("SERVICE3");
yield return new Uri("SERVICE4");
yield return new Uri("SERVICE5");
}


public static int Main(params string[] args)
{
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
foreach (Uri uri in GetServiceUris())
{
try
{
IService client = ChannelFactory<iservice>.CreateChannel(basicHttpBinding, uri);

if (client.DoWork())
break;
}
catch
{
}
}
return 0;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900