What happens when a WCF client specifies multiple endpoints for the same contract?

后端 未结 1 477
你的背包
你的背包 2021-01-18 09:46

Will it consume from all of them? Will it throw an exception?

1条回答
  •  孤街浪徒
    2021-01-18 10:35

    You can have multiple endpoints for the same contract and different addresses in your clieint config, no problem.

    They need to be separated by a unique name= attribute on the tag.

    
      
      
    
    

    When you create your client proxy, you need to provide the name of the endpoint you want to use:

    YourClient client = new YourClient("netTcpEndpoint");
    

    You can no longer just instantiate your client and expect it to find "the" endpoint to use, since there are multiple (and there's no way to define one as the "default" which gets used if nothing is specified, unfortunately).

    Other than that - no problems should arise, I think.

    0 讨论(0)
提交回复
热议问题