Initialization
HX-Rd edited this page Mar 9, 2018
·
2 revisions
Solid.AspNetCore.Extensions.Wcf is designed to work with the Startup class and IServiceCollection.
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// MyWcfService is an implementation of an interface that is defined
// as a service contract using the ServiceContractAttribute in System.ServiceModel
services.AddWcfServiceWithMetadata<MyWcfService>();
}
public void Configure(IApplicationBuilder builder)
{
// IMyWcfServiceContract is the service contract that MyWcfService implements.
// The Wcf service will be hosted as /service using the BasicHttpBinding
builder.UseWcfService<MyWcfService, IMyWcfServiceContract>("/service");
}
}
There are more options that can be used during startup.
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// MyWcfService is an implementation of an interface that is defined
// as a service contract using the ServiceContractAttribute in System.ServiceModel
services
.AddWcfServiceWithMetadata<MyWcfService>()
.AddDefaultBinding<WSHttpBinding>();
}
public void Configure(IApplicationBuilder builder)
{
// IMyWcfServiceContract is the service contract that MyWcfService implements.
// The Wcf service will be hosted as /service using the WSHttpBinding
builder.UseWcfService<MyWcfService, IMyWcfServiceContract>("/service");
}
}
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// MyWcfService is an implementation of an interface that is defined
// as a service contract using the ServiceContractAttribute in System.ServiceModel
services.AddWcfServiceWithMetadata<MyWcfService>();
}
public void Configure(IApplicationBuilder builder)
{
// IMyWcfServiceContract is the service contract that MyWcfService implements.
builder.UseWcfService<MyWcfService>("/service", b =>
{
// The Wcf service will be hosted as /service using the BasicHttpBinding
b.AddServiceEndpoint<IMyWcfServiceContract>();
// The Wcf service will be hosted as /service/ws using the WSHttpBinding
b.AddServiceEndpoint<IMyWcfServiceContract>(new WSHttpBinding(), "ws");
});
}
}