20 September 2012

Specify Client Side Endpoints in WCF

When we create a ChannelFactory at the client side, we need to specify the client side endpoint. We can achive this at code as well as at the configuration page.

Through Code :

This code allow you to specify the binding type as well as the endpoint address.

This approach is used when we want to force a client to use a particular endpoint or you want to create a channel at runtime. You need to pass this endpoint information at the runtime.

The other way to do this is, tell the ChannelFactory to go and read the endpoint from the configuration file.

Through Config file :

 
httpEndpoint is a string. It is name of the endpoint found in the configuration file.
 
Let us see our configuration file, which will make the picture more clear :
 
 

It looks very similar to the server side config model except the tag '<'Client'>' specified in the config file which contain the endpoint .

Second difference is that here at client side we have an endpoint name, which we don't find in a service side endpoint tags in its config file.

We do specify the name of the endpoint at client side to refer that in our code.

 

No comments:

Post a Comment