none
How is endpoint and binding selected from config file. RRS feed

  • Question

  • If I instantiate a service client class (using no args constructor) then how does WCF select an endpoint if there are multiple endpoints with the same contract name? (The contract name also appears in the contract attribute on the client interface definition).

    I have a config with three endpoints that have the same contract name, they have different binding types (custom, basic etc) and refer to different binding configurations, that's fine but the have same contract (but their name attribute is different, in this case their name is the same string as their bindingConfiguration).

    THx

    Thursday, July 20, 2017 9:05 PM

Answers

  • Hi Korporal,

    >>If I instantiate a service client class (using no args constructor) then how does WCF select an endpoint if there are multiple endpoints with the same contract name?

    Could you send a request by a service client without providing endpoint name?

    As my experience, you will get exception when a service client without providing endpoint name if you define multiple endpoint address in app.config.

    Here is the complete exception.

    Additional information: An endpoint configuration section for contract 'WCFCustomBindingSvc.IService1'

    could not be loaded because more than one endpoint configuration for that contract was found.

    Please indicate the preferred endpoint configuration section by name.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 21, 2017 1:52 AM

All replies

  • Hi Korporal,

    >>If I instantiate a service client class (using no args constructor) then how does WCF select an endpoint if there are multiple endpoints with the same contract name?

    Could you send a request by a service client without providing endpoint name?

    As my experience, you will get exception when a service client without providing endpoint name if you define multiple endpoint address in app.config.

    Here is the complete exception.

    Additional information: An endpoint configuration section for contract 'WCFCustomBindingSvc.IService1'

    could not be loaded because more than one endpoint configuration for that contract was found.

    Please indicate the preferred endpoint configuration section by name.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 21, 2017 1:52 AM
  • Hi Korporal,

    >>If I instantiate a service client class (using no args constructor) then how does WCF select an endpoint if there are multiple endpoints with the same contract name?

    Could you send a request by a service client without providing endpoint name?

    As my experience, you will get exception when a service client without providing endpoint name if you define multiple endpoint address in app.config.

    Here is the complete exception.

    Additional information: An endpoint configuration section for contract 'WCFCustomBindingSvc.IService1'

    could not be loaded because more than one endpoint configuration for that contract was found.

    Please indicate the preferred endpoint configuration section by name.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Ah yes. that makes sense, I've been quickly trying to get a grasp of all this. The code I was looking at that had no endpoint (empty constructor) was NOT the one defined with multiple endpoints in the stuff I was looking at.

    This is a great help, thanks.

    Friday, July 21, 2017 3:50 PM