AsWcfClient and AsWcfService
Previously you would use the ActAs() method to let the WCF facility take care of the implementation, either with a WCF client or a WCF service. I didn't like that method as it was a bit too generic, it takes a object. I guess the WCF facility team didn't like it either, because the methods AsWcfClient and AsWcfService were added. The AsWcfClient takes either a IWcfEndpoint or a IWcfClientModel[] and the AsWcfService takes a IWcfServiceModel[]. This ways it's a lot more discoverable.IWcfClientFactory
The IWcfClientFacility provides a way to lazy-load WCF clients. This method uses the typed factory facility to work. With the typed factory facility you will be able resolve objects with parameters at runtime, without having a direct reference to your container. Krzysztof has written a great article about the typed factory facility, so check that out first.To get things working you need to add the typed factory facility to your container (note: at the time of writing the WCF facility requires the typed factory facility to be registered first). Next you make sure your service gets a IWcfClientFactory from the container, either through constructor injection or property injection. The IWcfClientFactory basicly has two methods, the GetClient to create a WCF client based on the parameters and Release to release a previously created WCF client. All GetClient overloads requires a generic type, this type will be type of the WCF client. The different GetClient overloads let you specify a IWcfClientModel, IWcfEndpoint, configuration name or the url. Don't forget to release your WCF client through the Release method on the IWcfClientFactory instance.
PublishMetadata
When you create a service using the WCF facility to provide the configuration, you will notice that you cannot add a service reference using visual studio (even if you would want that). The reason is that by default the WCF service doesn't expose the metadata (wsdl/mex). With the PublishMetadata method you will be able to expose metadata. You can use this method on a WcfServiceModel<T>, like the DefaultServiceModel. To also expose the wsdl you will need to call the EnableHttpGet method on the action:Component.For<IDateService>()
.ImplementedBy<DateService>()
.LifeStyle.Transient
.AsWcfService(new DefaultServiceModel()
.Hosted()
.AddBaseAddresses("http://localhost:3976/DateService.svc")
.AddEndpoints(WcfEndpoint.BoundTo(new BasicHttpBinding()).At("basic"))
.PublishMetadata(o => o.EnableHttpGet()))
\o/
ReplyDelete