英文:
Publish SOAP web service in .NET Core 6.0 to IIS
问题
I have seen several tutorials on how to publish a SOAP service made in .NET Core 6.0 in an IIS but I can't get it to work.
这是配置:
从在Visual Studio中执行项目时,可以正常打开:localhost:1234/Service.asmx
,但当将其发布到另一台计算机的IIS时,无法使其响应地址:http://LOCALHOST:1819/Service.asmx
。
是否有人能够为我提供一些正确配置发布到IIS的信息?能否给我一些建议或提供一些教程?
非常感谢
我尝试了几种配置,但在任何情况下都无法使该服务对我响应。
英文:
I have seen several tutorials on how to publish a SOAP service made in .NET Core 6.0 in an IIS but I can't get it to work.
This is the configuration:
From the execution of the project in Visual Studio it opens without problems: localhost:1234/Service.asmx
but when launching the publication to an IIS of another computer I can't get it to respond to the address: http://LOCALHOST:1819/Service.asmx
Can someone give me some information to correctly configure publishing to an IIS? Give me some advice or give me some tutorial?
Thank you so much
I have tried several configurations and in no case have I been able to get the service to respond to me.
答案1
得分: 1
对于另一个人:
本教程解释了如何使用.NET Core 6.0和SOAPCore包创建、配置和部署SOAP服务。主要步骤包括:
-
创建一个新的.NET Core 6.0项目(ASP.NET Core Web API)。
-
安装SOAPCore NuGet包。
-
实现SOAP服务合同(接口)和相应的服务实现。
-
在Program.cs文件中配置服务。示例:
using SoapCore; using SOAP_CORE_V1.Service; var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllers(); builder.Services.AddSoapCore(); builder.Services.AddSingleton<IService, Service>(); var app = builder.Build(); // 配置中间件 if (app.Environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); // 确保这一行存在 app.UseEndpoints(endpoints => { endpoints.MapControllers(); app.UseSoapEndpoint<IService>("/SOAP_CORE_V1.asmx", new SoapEncoderOptions()); }); app.Run();
-
在开发环境中使用IIS Express和Visual Studio进行调试和运行服务。示例:
http://LOCALHOST:12345/SOAP_CORE_V1.asmx
-
使用dotnet publish或Visual Studio发布应用程序。
-
在IIS中创建一个新的网站或应用程序,指向发布的输出文件夹。
-
为生产环境配置web.config文件。
在web.config文件中将ASPNETCORE_ENVIRONMENT变量设置为"Production"。示例:<?xml version="1.0" encoding="utf-8"?> <configuration> <location path="." inheritInChildApplications="false"> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="dotnet" arguments=".\SOAP_CORE_V1.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" > <environmentVariables> <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" /> </environmentVariables> </aspNetCore> </system.webServer> </location> </configuration>
按照这些步骤后,SOAP服务应该在HTTP://ip:port/SOAP_CORE_V1.asmx
上运行并可访问。
英文:
For another person:
This tutorial explained how to create, configure, and deploy a SOAP service using .NET Core 6.0 and the SOAPCore package. The main steps included:
Creating a new .NET Core 6.0 project. (ASP NET CORE Web API)
Installing the SOAPCore NuGet package.
Implementing a SOAP service contract (interface) and the corresponding service implementation.
Configuring the service in the Program.cs file. Example:
using SoapCore;
using SOAP_CORE_V1.Service;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddSoapCore();
builder.Services.AddSingleton<IService, Service>();
var app = builder.Build();
// Configura el middleware
if (app.Environment.IsDevelopment()) {
app.UseDeveloperExceptionPage();
}
app.UseRouting(); // Asegúrate de que esta línea esté presente
app.UseEndpoints(endpoints => {
endpoints.MapControllers();
app.UseSoapEndpoint<IService>("/SOAP_CORE_V1.asmx", new SoapEncoderOptions());
});
app.Run();
Debugging and running the service in a development environment using IIS Express and Visual Studio. EXAMPLE:
http://LOCALHOST:12345/SOAP_CORE_V1.asmx
Publish the application using dotnet publish or Visual Studio.
Install the ASP.NET Core module on the IIS server
Create a new website or application in IIS, pointing to the published output folder.
Configure the web.config file for the production environment.
Set the ASPNETCORE_ENVIRONMENT variable to "Production" in the web.config file. EXAMPLE:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\SOAP_CORE_V1.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" >
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
</configuration>
After following these steps, the SOAP service should be running and accessible in : HTTP://ip:port/SOAP_CORE_V1.asmx
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论