Custom WCF Proxy

TL;DR

Explains how to create custom WCF proxies in .NET to avoid redundant class generation and object conversion when consuming Windows Communication Foundation services.

29 May 2007
Written by Martin Hinshelwood
1 minute read
Comments
Subscribe

The think that always annoys me with web services is that when you connect to it and generate the proxy it always generates proxies for all of the extra classes and interfaces as well, even when you have them available. This means that you always have to write convertors or adapters to convert one object type to another even though they are the same object (only core class and proxy of that class).

I decided to solve the problem by creating custom proxies for my Windows Communication Foundation services. What you need to do is add a reference to your DataContract and ServceContract assemblies and do the following:

Friend Class SubscriptionsClient
      Inherits System.ServiceModel.DuplexClientBase(Of Services.Contracts.ISubscriptions)
      Implements Services.Contracts.ISubscriptions

End Class

This way you have no need of a convertors or adapters between object types. Obviously this only works for .NET to .NET implementations of servers, you Java guys are still on your own, but it a usefully tool to add to your arsenal.

Technorati Tags: .NET  SOA  WCF

Comments
Subscribe

What to read next

Article

Creating a custom proxy class

Learn how to build a custom proxy class in .NET 3.0 for duplex communication, enabling maintainable code and easy updates when service …

Read article
Article

Creating WCF Service Host Programmatically

Explains how to programmatically create and configure a WCF Service Host in .NET, including base addresses, endpoints, bindings, and service …

Read article
Article Engineering Excellence

Creating a managed service factory

Explains how to build a managed service factory to access and manage local or remote services across multiple servers, supporting flexible …

Read article
Article

TFS Gotcha (Exception Handling)

Explains how to handle non-serialisable Team Foundation Server exceptions in WCF by creating custom serialisable exceptions for reliable …

Read article