Service code:
public static void StartService()
{
var windsorContainer = new WindsorContainer()
.AddFacility<WcfFacility>()
.Register(Component.For<IDateService>()
.ImplementedBy<DateService>()
.DependsOn(new { number = 42 })
.AsWcfService(new DefaultServiceModel().AddEndpoints(
WcfEndpoint.BoundTo(new NetTcpBinding { PortSharingEnabled = true })
.At(“net.tcp://localhost:8063/DateService”)
).PublishMetadata()
));
}
Client Code:
public static string InvokeWcfService()
{
var container = new WindsorContainer().AddFacility<WcfFacility>();
container.Register(Component
.For<IDateService>()
.AsWcfClient(DefaultClientModel
.On(WcfEndpoint.BoundTo(new NetTcpBinding())
.At(“net.tcp://localhost:8063/DateService”)))
.LifeStyle.Transient
);
var dateService = container.Resolve<IDateService>();
string message = dateService.SaySomething(“123”);
return message;
}
Complete sample source code be downloaded here.