Using ChannelFactory to consume a WCF service

When consuming a WCF service, it is common to generate a strong-typed client proxy class (either through Visual Studio's Add Service Reference context menu item or .NET SDK's Svcutil.exe tool) for invoking service operation. However, there are many cases in which we will need to get rid of this kind of auto-generated service proxy class. For example, we may need to directly reuse the existing types (including the ServiceContract type and custom data types) used in the service definition, or we might just need a lightweight component to invoke a service operation. For such scenarios, we can use the ChannelFactory class to directly communicate with the target WCF service endpoint.

How to do it...

Here ...

Get Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.