O'Reilly logo

Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications by Steven Cheng

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating a service proxy in code

In most cases, we will create the WCF service proxy types via Visual Studio's Add Service Reference option or the Svcutil.exe tool in the .NET SDK. Both of them actually import the metadata from the WCF service and generate proxy types from it. In addition to these kinds of static proxy generation approaches, WCF also provides powerful a interface for programmatically creating service proxy types.

How to do it...

To generate the client proxy types in code, we need to reference the necessary assemblies and import the proper namespaces. Following are the namespaces that contain those key types for generating the service proxy dynamically:

using System.ServiceModel; using System.ServiceModel.Description; using System.CodeDom; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required