WcfFacility Hello World

WcfFacility is one facilities of Castle Windsor facilities that helps you ignoring adding service reference by Visual Studio. With WcfFacility you can ease server and client service management. Before starting this sample I searched for and found a good starting point here. Unfortunately this sample was usng .svc file. As I didn’t want to use .svc file I wrote my own hello world sample with Wcf Facility:

Service code:

        public static void StartService()
            var windsorContainer = new WindsorContainer()
                    .DependsOn(new { number = 42 })
                    .AsWcfService(new DefaultServiceModel().AddEndpoints(
                            WcfEndpoint.BoundTo(new NetTcpBinding { PortSharingEnabled = true })

Client Code:

        public static string InvokeWcfService()
            var container = new WindsorContainer().AddFacility<WcfFacility>();

                .On(WcfEndpoint.BoundTo(new NetTcpBinding())

            var dateService = container.Resolve<IDateService>();
            string message = dateService.SaySomething(“123”);

            return message;

Complete sample source code be downloaded here.

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *