1
votes

some time clients do not add wcf service reference rather they establish the connection with wcf service through channel factory. i like to know in details when we use channel factory or add service reference then how wcf service get wcf service meta data at client side. i search Google lot to know and have in-depth write up but fail to get one. so please redirect me to right article which discuss in great detail about wcf service discovery at client side.

what is the difference between wcf service add reference & creating proxy through channel factory ?

i guess when we create wcf proxy with channel factory then every time when we run app then every time proxy is created. so i think this process is slower than add service reference because when we add service reference then proxy is created only once.

when we should go to use channel factory. please tell me the situation when channel factory would be the best option. thanks

1

1 Answers

0
votes

Actually there's very little difference. If you look at the code that Add Service Reference creates you'll see that it uses ChannelFactory internally.

The best resource to understand what happens when you use Add Service Reference or do it yourself manually is Miguel Castro's WCF the Manual Way…the Right Way

Also, you can read the section on "Adding Behaviors to the Runtime" of Extending WCF with Custom Behaviors, it explains how the metadata is handled.

Basically when you host the service (create a ServiceHost, either explicitly by newing up a ServiceHost or when you host your service in IIS and it gets created by the IHttpHandler that handles the .svc file) the type is read first (looking for attributes) and then the configuration file (web/app.config). The same happens in the client, although it is not very common to have annotations in the contract interface in the client.