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

Will he consume of all? Does this raise an exception?

+6
wcf wcf-client endpoints
source share
1 answer

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

They must be separated by a unique attribute name= in the <endpoint> .

 <client> <endpoint name="tcpEndpoint" address="net.tcp://server:8888/SomeService" binding="netTcpBinding" contract="IYourService" /> <endpoint name="httpEndpoint" address="http://server:8777/SomeService" binding="basicHttpBinding" contract="IYourService" /> </client> 

When creating a client proxy, you need to specify the name of the endpoint that you want to use:

 YourClient client = new YourClient("netTcpEndpoint"); 

You can no longer simply create an instance of your client and expect it to find an "endpoint" to use, since there are several (and there is no way to define one of them as a "default", which will be used if nothing is specified, to unfortunately).

Other than that, I think no problems will arise.

+11
source share

All Articles