Publish SOAP web service in .NET Core 6.0 to IIS.

huangapple go评论67阅读模式
英文:

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.

这是配置:

Publish SOAP web service in .NET Core 6.0 to IIS.

从在Visual Studio中执行项目时,可以正常打开:localhost:1234/Service.asmx,但当将其发布到另一台计算机的IIS时,无法使其响应地址:http://LOCALHOST:1819/Service.asmx

Publish SOAP web service in .NET Core 6.0 to IIS.

是否有人能够为我提供一些正确配置发布到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:

Publish SOAP web service in .NET Core 6.0 to IIS.

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

Publish SOAP web service in .NET Core 6.0 to IIS.

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服务。主要步骤包括:

  1. 创建一个新的.NET Core 6.0项目(ASP.NET Core Web API)。

  2. 安装SOAPCore NuGet包。

  3. 实现SOAP服务合同(接口)和相应的服务实现。

  4. 在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();
    
  5. 在开发环境中使用IIS Express和Visual Studio进行调试和运行服务。示例:

    http://LOCALHOST:12345/SOAP_CORE_V1.asmx

  6. 使用dotnet publish或Visual Studio发布应用程序。

  7. 在IIS服务器上安装ASP.NET Core模块

  8. 在IIS中创建一个新的网站或应用程序,指向发布的输出文件夹。

  9. 为生产环境配置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&lt;IService, Service&gt;();

var app = builder.Build();

// Configura el middleware
if (app.Environment.IsDevelopment()) {
  app.UseDeveloperExceptionPage();
}

app.UseRouting(); // Aseg&#250;rate de que esta l&#237;nea est&#233; presente

app.UseEndpoints(endpoints =&gt; {
  endpoints.MapControllers();
  app.UseSoapEndpoint&lt;IService&gt;(&quot;/SOAP_CORE_V1.asmx&quot;, 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:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;configuration&gt;
  &lt;location path=&quot;.&quot; inheritInChildApplications=&quot;false&quot;&gt;
    &lt;system.webServer&gt;
      &lt;handlers&gt;
        &lt;add name=&quot;aspNetCore&quot; path=&quot;*&quot; verb=&quot;*&quot; modules=&quot;AspNetCoreModuleV2&quot; resourceType=&quot;Unspecified&quot; /&gt;
      &lt;/handlers&gt;
      &lt;aspNetCore processPath=&quot;dotnet&quot; arguments=&quot;.\SOAP_CORE_V1.dll&quot; stdoutLogEnabled=&quot;false&quot; stdoutLogFile=&quot;.\logs\stdout&quot; hostingModel=&quot;inprocess&quot; &gt;
        &lt;environmentVariables&gt;
          &lt;environmentVariable name=&quot;ASPNETCORE_ENVIRONMENT&quot; value=&quot;Production&quot; /&gt;
        &lt;/environmentVariables&gt;
      &lt;/aspNetCore&gt;
    &lt;/system.webServer&gt;
  &lt;/location&gt;
&lt;/configuration&gt;

After following these steps, the SOAP service should be running and accessible in : HTTP://ip:port/SOAP_CORE_V1.asmx

huangapple
  • 本文由 发表于 2023年3月21日 02:23:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75793977.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定