The configuration

Add as Link the file HostConfiguration.config and edit properties in order to copy if newer.

The Program.cs

internal class Program
{
internal static IUnityContainer Container = new UnityContainer();

static Program()
{
WcfClientContainerHelper.Setup(Container);
Container.RegisterType<IConsoleAdapter, ConsoleAdapter>();
Container.RegisterType<IEntryPoint, EntryPoint>();
}

internal static void Main(string[] args)
{
var entryPoint = Container.Resolve<IEntryPoint>();
entryPoint.Run(EnvMode.Prod);
}
}

The EntryPoint.cs class

In order to avoid static dependencies into Main Method, we use an EntryPoint

public class EntryPoint : IEntryPoint
{
internal static ILog Logger = LogManager.GetLogger(typeof(EntryPoint));
internal IUnityContainer Container { get; set; }

public EntryPoint(IUnityContainer container)
{
Container = container;
}

public void Run(EnvMode envMode)
{
var serviceClientFactory = Container.Resolve<IServiceClientFactory>();
var consoleAdapter = Container.Resolve<IConsoleAdapter>();

var wcfClient = serviceClientFactory.CreateProxy<IPouet>(envMode);

var toto = wcfClient.HelloWorld();
Logger.Debug(toto.Name);

try
{
wcfClient.HelloWorldException();
}
catch (FaultException<MyFault> e)
{
Logger.Error(e.Detail.Info);
}

consoleAdapter.Read();

}
}

There is 2 way to create client over WCF services.

Wcf client without cache : with class ServiceClientFactory.
Wcf client with cache : with class ServiceClientCacheFactory.

The Cache Component can be reused, cause it's a Castle Interceptor (added to the WcfInterceptor)

All part of this code is in Framework.Wcf.Consumer and Framework.Wcf.ServiceImplementation for hosting.

Last edited Apr 25, 2013 at 6:53 AM by cboudereau, version 3

Comments

No comments yet.