Program.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. // Configurar endpoints SOAP
  23. app.UseEndpoints(endpoints =>
  24. {
  25. endpoints.UseSoapEndpoint<IWsServicioDeInformacion>(
  26. "/WsServicioDeInformacion.svc",
  27. new SoapEncoderOptions(),
  28. SoapSerializer.DataContractSerializer);
  29. endpoints.UseSoapEndpoint<IWsServicioDeInformacion>(
  30. "/WsServicioDeInformacion.asmx",
  31. new SoapEncoderOptions(),
  32. SoapSerializer.XmlSerializer);
  33. });
  34. app.Run();