Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6006719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:34:49+00:00 2026-05-23T01:34:49+00:00

How to set fall-back endpoint. I’m having more than one endpoint specified in the

  • 0

How to set fall-back endpoint. I’m having more than one endpoint specified in the conifg file like follows. If the service was not accessible, then my client should check the next address specified in the list.

Client Configuration File:

<client>
  <endpoint address="http://192.168.1.4/SampleAppWeb/Services/SampleAppService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISampleAppService"
        contract="SampleAppServiceReference.ISampleAppService" name="BasicHttpBinding_ISampleAppService" />
  <endpoint address="http://172.168.12.121/SampleAppWeb/Services/SampleAppService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISampleAppService"
        contract="SampleAppServiceReference.ISampleAppService" name="BasicHttpBinding_ISampleAppService1" />
  <endpoint address="http://127.0.0.1/Services/SampleAppWeb/SampleAppService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISampleAppService"
        contract="SampleAppServiceReference.ISampleAppService" name="BasicHttpBinding_ISampleAppService2" />
  <endpoint address="http://172.168.111.115/Services/SampleAppWeb/SampleAppService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISampleAppService"
        contract="SampleAppServiceReference.ISampleAppService" name="BasicHttpBinding_ISampleAppService3" />          
</client>

Code Behind:

var pass = new SampleAppServiceReference.SampleAppServiceClient("BasicHttpBinding_ISampleAppService3");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:34:49+00:00Added an answer on May 23, 2026 at 1:34 am

    WCF itself doesn’t have any built-in feature for this, but you can easily create a class which will do the retrying for you. The example below shows one such way. Notice that if your binding uses session, you may need to recreate the client (instead of simply reusing it), as its channel will likely be faulted if an error happens.

    public class StackOverflow_4968244
    {
        [ServiceContract]
        public interface ITest
        {
            [OperationContract]
            int Add(int x, int y);
        }
        public class Service : ITest
        {
            public int Add(int x, int y)
            {
                Console.WriteLine("Request at service: {0}", OperationContext.Current.Host.BaseAddresses[0]);
                if (new Random().Next(3) == 0)
                {
                    throw new InvalidOperationException("Random error");
                }
    
                return x + y;
            }
        }
        public class Client : ClientBase<ITest>, ITest
        {
            public Client(string address) : base(new BasicHttpBinding(), new EndpointAddress(address)) { }
    
            public int Add(int x, int y)
            {
                return this.Channel.Add(x, y);
            }
        }
        public class SafeClient : ITest
        {
            List<Client> clients;
            public SafeClient(params Client[] clients)
            {
                this.clients = new List<Client>(clients);
            }
    
            public int Add(int x, int y)
            {
                foreach (var client in this.clients)
                {
                    try
                    {
                        return client.Add(x, y);
                    }
                    catch (CommunicationException)
                    {
                        Console.WriteLine("Error calling client {0}, retrying with next one", client.Endpoint.Address.Uri);
                    }
                }
    
                throw new InvalidOperationException("All services seem to be down");
            }
        }
    
        public static void Test()
        {
            string baseAddress1 = "http://" + Environment.MachineName + ":8000/Service";
            string baseAddress2 = "http://" + Environment.MachineName + ":8001/Service";
            string baseAddress3 = "http://" + Environment.MachineName + ":8002/Service";
            ServiceHost host1 = new ServiceHost(typeof(Service), new Uri(baseAddress1));
            ServiceHost host2 = new ServiceHost(typeof(Service), new Uri(baseAddress2));
            ServiceHost host3 = new ServiceHost(typeof(Service), new Uri(baseAddress3));
            host1.AddServiceEndpoint(typeof(ITest), new BasicHttpBinding(), "");
            host2.AddServiceEndpoint(typeof(ITest), new BasicHttpBinding(), "");
            host3.AddServiceEndpoint(typeof(ITest), new BasicHttpBinding(), "");
            host1.Open();
            host2.Open();
            host3.Open();
            Console.WriteLine("Hosts opened");
    
            SafeClient safeClient = new SafeClient(
                new Client(baseAddress1),
                new Client(baseAddress2),
                new Client(baseAddress3));
            for (int i = 0; i < 20; i++)
            {
                Console.WriteLine(safeClient.Add(i, 10));
            }
    
            Console.Write("Press ENTER to close the host");
            Console.ReadLine();
            host1.Close();
            host2.Close();
            host3.Close();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I set up a fall-back file for an IceCast server?
I have a set of data points in 3D space which apparently all fall
I would like to make an async GET request that returns back a document
I would like find the correct syntax for the SET line: Doctrine_Query::create() ->update('Media m')
:set ic ignores the case. How do you unset this?
Set<Type> union = new HashSet<Type>(s1); union.addAll(s2); AND Set <Type> union = new HashSet<Type>(); union.addAll(s1);
Set content of table ... ViewState[Table1] = Table1; // When remove this line, table
I set up a website to use SqlMembershipProvider as written on this page .
I set a passphrase when creating a new SSH key on my laptop. But,
The set up for apache-jmeter allows for a URL to be sent to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.