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

  • Home
  • SEARCH
  • 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 6163489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:50:03+00:00 2026-05-23T21:50:03+00:00

I have a WCF service XYZ that will be deployed on a number of

  • 0

I have a WCF service XYZ that will be deployed on a number of hosts. Each such service may have a connection to another XYZ service deployed on one of the other hosts. It’s a distributed system where the states will differ between the services.

In order to communicate it doesn’t really make sense for me to “Add Service Reference” in Visual Studio because that will just add redundancy (the service already knows what it’s going to be communicating with).

So currently my idea is to specify the other service endpoints in the App.config files of each service. For example:

<client>
  <endpoint name="BEL" 
            address="tcp://us.test.com:7650/OrderManagementService"
            binding="tcpBinding"
            contract="IOrderManagementService"/>
  <endpoint name="BEL2"
      address="tcp://us.test2.com:7650/OrderManagementService"
      binding="tcpBinding"
      contract="IOrderManagementService"/>
</client>

Now, I just want a way to read these settings and create ChannelFactories and Channels in my code. However, it’s turning out to be a hassle to do this.

Two questions: am I doing things right; and if so, what’s the best way to extract these values from the config file?

  • 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-23T21:50:03+00:00Added an answer on May 23, 2026 at 9:50 pm

    Creating channels directly isn’t hard, and all the endpoint configuration is read in for you. Try something like this:

    var factory = new ChannelFactory<IOrderManagementService>("BEL");
    var proxy = factory.CreateChannel();
    // call methods on proxy
    proxy.Close();
    

    Note that the proxy needs closing properly (which means calling Close or Abort correctly) as soon as you have finished with it. However, you can leave the factory open for long periods, even in a cache.

    You can encapsulate this into helper methods to make the calling code simple:

    public static ChannelFactory<TContract> NewChannelFactory<TContract>(string endpointConfigurationName) where TContract : class {
        // TODO: Cache the factory in here for better performance.
        return new ChannelFactory<TContract>(endpointConfigurationName);
    }
    
    public static void Invoke<TContract>(ChannelFactory<TContract> factory, Action<TContract> action) where TContract : class {
        var proxy = (IClientChannel) factory.CreateChannel();
        bool success = false;
        try {
            action((TContract) proxy);
            proxy.Close();
            success = true;
        } finally {
            if(!success) {
                proxy.Abort();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have WCF service that has http and net.tcp endpoints. I have deployed the
I have a WCF service that accesses a SQL database to fetch data .
I have a WCF service that I need to call in a ASP.NET web
I have a WCF service that I can debug. I put a breakpoint in
I have a WCF service that can return large amount of data depending on
I have a WCF service that needs to hosted using basicHttpBinding using SSL. So
I have WCF Service that returns data as DataTable type. I want to insert
I have WCF service that uses raw messages (Message class). 1) Service side: [DataContract]
I have WCF service that uses wsHttpBinding and authentication with certificate. I run this
I have WCF service that is IIS-hosted and I have to send binary data

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.