Program.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Microsoft.Extensions.DependencyInjection.Extensions;
  2. using SoapCore;
  3. using SoapService.Services;
  4. var builder = WebApplication.CreateBuilder(args);
  5. // Agregar servicios al contenedor
  6. builder.Services.AddSoapCore();
  7. builder.Services.TryAddSingleton<IWsServicioDeInformacion, WsServicioDeInformacion>();
  8. builder.Services.AddControllers();
  9. builder.Services.AddEndpointsApiExplorer();
  10. // Configurar Logging
  11. builder.Logging.AddConsole();
  12. builder.Logging.AddDebug();
  13. // Configurar URL y Kestrel
  14. builder.WebHost.UseKestrel(options =>
  15. {
  16. options.ListenAnyIP(5050);
  17. });
  18. var app = builder.Build();
  19. // Configurar el pipeline HTTP
  20. app.UseHttpsRedirection();
  21. app.UseRouting();
  22. // Agregar redirección a la Wiki en la ruta raíz
  23. app.MapGet("/", context =>
  24. {
  25. context.Response.Redirect("https://git.mz.uy/marianozunino/dnic-soap/wiki/?action=_pages");
  26. return Task.CompletedTask;
  27. });
  28. // Configurar endpoints SOAP
  29. app.UseEndpoints(endpoints =>
  30. {
  31. endpoints.UseSoapEndpoint<IWsServicioDeInformacion>(
  32. "/WsServicioDeInformacion.svc",
  33. new SoapEncoderOptions(),
  34. SoapSerializer.DataContractSerializer);
  35. endpoints.UseSoapEndpoint<IWsServicioDeInformacion>(
  36. "/WsServicioDeInformacion.asmx",
  37. new SoapEncoderOptions(),
  38. SoapSerializer.XmlSerializer);
  39. });
  40. app.Run();