How do I use the Castle WcfFacility and have it use the standard Wcf config file settings?
If开发者_JS百科 I register like so:
container.Register(
AllTypes.Pick()
.FromAssemblyNamed("{ServicesAssembly}") // <-- service assembly here
.If(type => type.Name.EndsWith("Service"))
.WithService.FirstInterface()
.Configure(configurer => configurer.LifeStyle.Transient)
.Configure(configurer => configurer.Named(configurer.Implementation.Name))
.Configure(configurer => configurer.ActAs(new DefaultServiceModel()))
);
I receive the following error:
Service '{name}' has zero application (non-infrastructure) endpoints.
If I leave off:
.Configure(configurer => configurer.ActAs(new DefaultServiceModel()))
it seems as though the behaviors in the config are ignored.
What is the correct usage here?
OK, figured it out :)
I register like so:
container.Register(
AllTypes.Pick()
.FromAssemblyNamed("{ServicesAssembly}") // <-- service assembly here
.If(type => type.Name.EndsWith("Service"))
.WithService.FirstInterface()
.Configure(configurer => configurer.LifeStyle.Transient)
.Configure(configurer => configurer.Named(configurer.Implementation.Name))
.Configure(configurer => configurer.ActAs(new DefaultServiceModel().Hosted()))
);
The Hosted() is there to indicate that I am hosting the services; else is seems as though the WCF Facility will try to host them, resulting in port conflicts.
So the problem was that the name of the service in the config file has to be the full type name of the implementation. If not one receives an error stating something along the lines of no endpoints defined. So the service name is not the same as the name specified in windsor.
You're almost there.
You need this:
.ActAs(new DefaultClientModel(WcfEndpoint.FromConfiguration( <<key In Configuration>> )));
精彩评论