CoreWCF project is a port of Windows Communication Framework (WCF) to .NET Core. The main goal of this project is to enable existing WCF projects to move to .NET Core. After 21 months of public development, CoreWCF has reached its first GA release.
During the development of the prototype, the CoreWCF project caught the attention of the Amazon AWS team. Which led to the support of WS-* protocols (WS-Security, WS-SecureConversation) and token authentication credential types with the TransportWithMessageCredentials security mode. As stated on the CoreWCF 0.1.0 GA Release note: This is a significant step towards supporting WS-Federation to enable moving enterprise WCF services to CoreWCF hosted on a cloud platform
The 0.1. GA release and 21 months of development are connected to two key things: removal of Asynchronous Programming Model (APM) API's and code, and removing direct native system calls and IO code. Besides these two changes, CoreWCF also moved to a request push pipeline model with adoption to the ASP.NET Core middleware pattern.
Using CoreWCF there is a minimal amount of the code required in order to configure it with the model of ASP.NET Core. The configuration is done in two familiar methods of ASP.NET Core in Startup class; the methods are ConfigureServices and Configure.
Inside of the ConfigureServices
method, the single and simple method is required to add in order to have WCF support enabled.
public void ConfigureServices(IServiceCollection services)
{
services.AddServiceModelServices();
}
Inside the Configure
method, there is the usage of the extension method UseServiceModel (this IApplicationBuilder app) with the delegate which configures CoreWCF.
public void Configure(IApplicationBuilder app)
{
app.UseServiceModel(builder =>
{
builder.AddService<MyService>();
builder.AddServiceEndpoint<MyService, IMyService>(new BasicHttpBinding(), "/basic");
});
}
Using the AddService method the registration for the service of the type TService
is done; alongside that the service also needs at least one endpoint added to the builder for that kind of service type.
The mechanism for getting the instance of the service is based on a couple of steps; the first of them is to look in DI to see if there is an implementation available. If there is no implementation, the fallback for the creation of an instance is with the usage of reflection, the same way that standard WCF does it.
If either InstanceContextMode.PerSession or InstanceContextMode.PerCall is used, CoreWCF will request an instance from DI if available each time an instance is needed. It will fall back to the same behaviour as WCF if the type is not registered in DI. This allows injecting other dependencies such as loggers into the service instances without having to implement IInstanceContextProvider to do so.
If the WCF Core client NuGet package System.ServiceModel.Primitives
is referenced, CoreWCF supports the System.ServiceModel
namespace contract attributes like ServiceContract and OperationContract. This enables the sharing of contract assemblies between the server and the client.CoreWCF versions of these attributes are also available too so the dependency on the WCF Core client NuGet package is not needed.
The release road map provides a high-level overview and reveals that the goal of the 1.0 release is to make migration from .NET Framework as smooth as possible. With dependency on ASP.NET, Core 2.1 porting process from WCF service to CoreWCF is done while running it on .NET Framework. There are also a couple of discussions opened on the GitHub repo which can be explored.