Search code examples
wcfweb-configenvironment

Connection to the WCF in different environments


I have done some research on connecting to the WCF in different environments. I know that I can use the tag in the web.config to specify the addresses for the endpoint in the different environment.

What I don't understand (and can't find answer to) is that if I have specified the endpoint in all environments in the web.config of my client app, how does the client app know which one to connect?

Thanks!


Solution

  • Per your description, I can’t understand the meaning of “different environments”. In my opinion, the client app used to connect the server is accomplished by using the client proxy class. Alternatively, we create a channel factory to communicate with the server. These above ways all need a service endpoint address.
    For the client proxy class, we specify the name of the endpoint in order to instantiate a proxy class when the auto-generated configuration has multiple service endpoints.

    ServiceReference1.ServiceClient client = new ServiceClient("BasicHttpBinding_IService1");
    

    For the way that we connect the service by using Channel factory, we ordinarily specify the service address manually in code.
    Feel free to let me know if there is anything I can help with.