Mainly there are two ways to create a WCF Client or calling a WCF Service.
- Channel Factory
- 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:
- Using Visual Studio by adding service reference to the client application.
- Using SvcUtil.exe command-line utility
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.
Reference books, you may like:Programming WCF Services: Design and Build Maintainable Service-Oriented Systems
WCF Multi-Layer Services Development with Entity Framework, 4th Edition
Learning WCF: A Hands-on Guide
WSHttpBinding binding = new WSHttpBinding();
EndpointAddress endpoint = new EndpointAddress("http://localhost/WcfService/MyService.svc/ws");
ChannelFactorychannelFactory = new ChannelFactory(binding,endpoint );
IMyService channel = channelFactory.CreateChannel();
//calling service operation
Difference between WCF proxy and Channel Factory:
© 2015, admin. All rights reserved.