田工版本初次提交

This commit is contained in:
2025-12-11 14:13:27 +08:00
parent ab6e620f8e
commit fe7f5313bc
146 changed files with 86546 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
namespace MySOAP
{
public class CalculatorService : ICalculatorService
{
public double Add(double a, double b)
{
return a + b;
}
public double Subtract(double a, double b)
{
return a - b;
}
public double Multiply(double a, double b)
{
return a * b;
}
public double Divide(double a, double b)
{
if (b == 0)
{
throw new DivideByZeroException();
}
return a / b;
}
}
}

View File

@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace MySOAP.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

View File

@@ -0,0 +1,20 @@
using System.ServiceModel;
namespace MySOAP
{
[ServiceContract]
public interface ICalculatorService
{
[OperationContract]
double Add(double a, double b);
[OperationContract]
double Subtract(double a, double b);
[OperationContract]
double Multiply(double a, double b);
[OperationContract]
double Divide(double a, double b);
}
}

13
MySOAP/MySOAP.csproj Normal file
View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SoapCore" Version="1.2.1.11" />
</ItemGroup>
</Project>

6
MySOAP/MySOAP.http Normal file
View File

@@ -0,0 +1,6 @@
@MySOAP_HostAddress = http://localhost:5220
GET {{MySOAP_HostAddress}}/weatherforecast/
Accept: application/json
###

24
MySOAP/MySOAP.sln Normal file
View File

@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySOAP", "MySOAP.csproj", "{BEBB9268-7AC5-F9EE-BCD7-F75423334851}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BEBB9268-7AC5-F9EE-BCD7-F75423334851}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BEBB9268-7AC5-F9EE-BCD7-F75423334851}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEBB9268-7AC5-F9EE-BCD7-F75423334851}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEBB9268-7AC5-F9EE-BCD7-F75423334851}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {88A70167-6316-4A1A-B72E-7B242BFE720E}
EndGlobalSection
EndGlobal

35
MySOAP/Program.cs Normal file
View File

@@ -0,0 +1,35 @@
using SoapCore;
namespace MySOAP
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
builder.Services.AddSoapCore();
builder.Services.AddSingleton<ICalculatorService, CalculatorService>();
builder.Services.AddControllers();
builder.Services.AddMvc();
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseRouting();
app.UseAuthorization();
_ = app.UseEndpoints(endpoints =>
{
endpoints.UseSoapEndpoint<ICalculatorService>("/Service.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer);
});
app.MapControllers();
app.Run();
}
}
}

View File

@@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:21282",
"sslPort": 0
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5220",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

13
MySOAP/WeatherForecast.cs Normal file
View File

@@ -0,0 +1,13 @@
namespace MySOAP
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

9
MySOAP/appsettings.json Normal file
View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}