Submit to Reddit      

ChannelAdam WCF Library — Version 1 Documentation

Quick Start

To get you started quickly, here is some sample code showing the basic usage.

Install NuGet Package

You can install the ChannelAdam.Wcf NuGet package from within Visual Studio, or find it on the gallery at

To install ChannelAdam WCF Library via the Package Manager Console, run the following command:

PM> Install-Package ChannelAdam.Wcf

How To Call a WCF Service

Let's assume for the duration of this documentation that there is a web service named FakeService and in Visual Studio we have generated a service reference and interface to FakeService, and there is now an IFakeService interface and a FakeServiceClient class to use. That is all normal and basic Visual Studio functionality.

Let's also assume that the service has the following operation signature:

int AddIntegers(int first, int second);

Below is sample code for how to use the ChannelAdam WCF Library ServiceConsumer and ServiceConsumerFactory to call the AddIntegers operation.

using ChannelAdam.ServiceModel;


//using (var service = ServiceConsumerFactory.Create<IFakeService>("BasicHttpBinding_IFakeService"))
using (var service = ServiceConsumerFactory.Create<IFakeService>(() => new FakeServiceClient()))
        int actual = service.Operations.AddIntegers(1, 1);

    // catch (FaultException<MyBusinessLogicType> fe)
    catch (FaultException fe)
        Console.WriteLine("Service operation threw a fault: " + fe.ToString());
    catch (Exception ex)
        Console.WriteLine("Technical error occurred while calling the service operation: " + ex.ToString());

Easy and no hassles.

There is no need to catch a CommunicationException or TimeOutException and try to perform the Close/Abort pattern, as the underlying channel is dealt with automatically for you by the ServiceConsumer.

Please see the other documentation pages for further details.

comments powered by Disqus