zhaw-dnet2/Tasks/Lab7/RankingServer/Program.cs

50 lines
1.6 KiB
C#

// See https://aka.ms/new-console-template for more information
using RankingServer;
using CoreWCF.Configuration;
using CoreWCF.Description;
using CoreWCF;
using System.Net;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.WebHost
.ConfigureKestrel(
(context, options) =>
{
options.AllowSynchronousIO = true;
})
.UseKestrel(
(context, options) =>
{
options.Listen(IPAddress.Loopback, 5000);
options.Listen(
IPAddress.Loopback,
5001,
listenOptions =>
{
listenOptions.UseHttps();
});
});
// Add support
builder.Services.AddServiceModelServices().AddServiceModelMetadata();
builder.Services.AddSingleton<IServiceBehavior, UseRequestHeadersForMetadataAddressBehavior>();
builder.Services.AddAuthorization();
builder.Services.AddAuthentication();
WebApplication app = builder.Build();
app.UseServiceModel(
builder =>
{
builder
.AddService<RankingService>((serviceOptions) => { })
.AddServiceEndpoint<RankingService, IRankingService>(new BasicHttpBinding(), "/RankingService/basichttp")
.AddServiceEndpoint<RankingService, IRankingService>(new WSHttpBinding(SecurityMode.Transport), "/RankingService/WSHttps");
});
ServiceMetadataBehavior serviceMetadataBehavior = app.Services.GetRequiredService<ServiceMetadataBehavior>();
serviceMetadataBehavior.HttpGetEnabled = true;
app.Logger.LogInformation("Starting Ranking Service…");
app.Run();