Please enable Javascript to correctly display the contents on Dot Net Tricks!

Difference between WCF Proxy and Channel Factory

  Author : Shailendra Chauhan
Updated On : 22 Nov 2014
Total Views : 56,378   
Support : All WCF
 

There are two ways : Proxy and Channel Factory; to create a WCF Client or calling a WCF Service. In this article, I am going to expose the difference between Proxy and Channel Factory.

  1. WCF Proxy

    A WCF proxy is a CLR class that exposes the service contract. A Service proxy class has the service contract operations and some additional operations for managing the proxy life cycle and the connection to the service.

    There are two ways to create a WCF proxy as given below:

    1. Using Visual Studio by adding service reference to the client application.

    2. Using SvcUtil.exe command-line utility.

  2. Channel Factory

    A channel factory creates channels of different types that are used by client to send messages to the service. ChannelFactory class is used with a known interface to create the channel. This approach is commonly used when you have access control to both the server and the client.

    WSHttpBinding binding = new WSHttpBinding();
    EndpointAddress endpoint = new EndpointAddress("http://localhost/WcfService/MyService.svc/ws");
    
    ChannelFactory<IMyService>channelFactory = new ChannelFactory<IMyService>(binding,endpoint );
    IMyService channel = channelFactory.CreateChannel();
    
    //calling service operation
    channel.DoWork();
    
    //Close channel
    channelFactory.Close();
    

Difference between WCF Proxy and Channel Factory

Proxy
Channel Factory
Only requires the service URL to access the service.
Requires direct access to the assembly which contains the service contract i.e. must have information about service interface.
Simple and easy to understand
Not easy since channels are complex and network-related
Proxy is best when your service is used by several applications.
Channel Factory is best when your service is tightly bound to a single application
Proxy can be created by using Visual Studio or SVCUtil tool.
ChannelFactory class is used to create channel and for accessing the service.
What do you think?

I hope you will enjoy the tips while programming with WCF. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

YOU MIGHT LIKE
Free Interview Books
 
COMMENTS (0)
14 DEC
ASP.NET MVC with AngularJS Development (online)

MON-FRI 07:30 AM- 09:00 AM IST

Know More
5 DEC
AngularJS Development (online)

Mon - Fri     6:30 AM-7:30 AM IST

3 DEC
AngularJS Development (offline)

SAT,SUN     11:00 AM-12:30 PM IST

3 DEC
MEAN Stack Development (offline)

Sat, Sun     (09:30 AM-11:00 AM IST)

26 NOV
ASP.NET MVC with AngularJS Development (offline)

(SAT,SUN)     03:30 PM-05:00 PM IST

24 NOV
ASP.NET MVC with AngularJS Development (online)

MON-FRI     09:30 PM-11:00 PM IST

12 NOV
ASP.NET MVC with AngularJS Development (offline)

SAT,SUN     08:00 AM-09:30 AM

3 NOV
ASP.NET MVC with AngularJS Development (online)

MON-FRI     07:30 AM-09:00 AM IST

25 OCT
.NET Development (offline)

Mon-Fri     9:00 AM-11:00 AM IST

BROWSE BY CATEGORY
 
RECENT ARTICLES
SUBSCRIBE TO LATEST NEWS
 
LIKE US ON FACEBOOK
 

Professional Speaks

+