Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ artifacts/
*.pidb
*.svclog
*.scc
*.lutconfig

# Chutzpah Test files
_Chutzpah*
Expand Down Expand Up @@ -251,3 +252,4 @@ paket-files/
.idea/
*.sln.iml
**/BenchmarkDotNet.Artifacts/

10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ Support ref\out params, exceptions. Works with legacy SOAP\WCF-clients.

The following frameworks are supported:

- .NET 8.0 (using ASP.NET Core 8.0)
- .NET Core 3.1 (using ASP.NET Core 3.1)
- .NET Standard 2.0-2.1 (using ASP.NET Core 2.1)
- .NET 10.0
- .NET 8.0
- .NET Standard 2.0-2.1

### Installing

`PM> Install-Package SoapCore`

There are 2 different ways of adding SoapCore to your ASP.NET Core website. If you are using ASP.NET Core 3.1 or higher with endpoint routing enabled (the default):

In Startup.cs:
In Startup.cs or Program.cs (for .NET 8+ minimal hosting):

```csharp
public void ConfigureServices(IServiceCollection services)
Expand Down
5 changes: 3 additions & 2 deletions samples/Client/Client.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.ServiceModel.Http" Version="4.8.1" />
<PackageReference Include="System.ServiceModel.Http" Version="8.0.*" />
</ItemGroup>

<ItemGroup>
Expand Down
22 changes: 22 additions & 0 deletions samples/Net10Client/Net10Client.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.ServiceModel.Duplex" Version="6.0.*" />
<PackageReference Include="System.ServiceModel.Federation" Version="10.0.*" />
<PackageReference Include="System.ServiceModel.Http" Version="10.0.*" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="10.0.*" />
<PackageReference Include="System.ServiceModel.Security" Version="6.0.*" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Models\Models.csproj" />
</ItemGroup>

</Project>
65 changes: 65 additions & 0 deletions samples/Net10Client/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.ServiceModel;
using Models;

namespace Net10Client
{
public class Program
{
public static void Main()
{
Console.WriteLine("NET 10 Client - Connecting to SOAP service...");

var binding = new BasicHttpBinding();
var endpoint = new EndpointAddress(new Uri($"http://{Environment.MachineName}:5060/Service.svc"));
using var channelFactory = new ChannelFactory<ISampleService>(binding, endpoint);
var serviceClient = channelFactory.CreateChannel();

try
{
var result = serviceClient.Ping("Hello from NET 10 Client");
Console.WriteLine("Ping method result: {0}", result);

var complexModel = new ComplexModelInput
{
StringProperty = Guid.NewGuid().ToString(),
IntProperty = int.MaxValue / 2,
ListProperty = new List<string> { "NET", "10", "test", "list" },
DateTimeOffsetProperty = new DateTimeOffset(2024, 12, 31, 13, 59, 59, TimeSpan.FromHours(1))
};

var complexResult = serviceClient.PingComplexModel(complexModel);
Console.WriteLine("PingComplexModel result. FloatProperty: {0}, StringProperty: {1}, ListProperty: {2}, DateTimeOffsetProperty: {3}, EnumProperty: {4}",
complexResult.FloatProperty, complexResult.StringProperty, string.Join(", ", complexResult.ListProperty),
complexResult.DateTimeOffsetProperty, complexResult.TestEnum);

serviceClient.VoidMethod(out var stringValue);
Console.WriteLine("Void method result: {0}", stringValue);

var asyncMethodResult = serviceClient.AsyncMethod().Result;
Console.WriteLine("Async method result: {0}", asyncMethodResult);

var xmlElement = System.Xml.Linq.XElement.Parse("<test>NET 10 string</test>");
serviceClient.XmlMethod(xmlElement);
Console.WriteLine("XmlMethod executed successfully");

var complexReturnModels = serviceClient.ComplexReturnModel();
Console.WriteLine("ComplexReturnModel results:");
foreach (var model in complexReturnModels)
{
Console.WriteLine(" Id: {0}, Name: {1}", model.Id, model.Name);
}

Console.WriteLine("\nAll tests completed successfully!");
}
catch (Exception ex)
{
Console.WriteLine("Error: {0}", ex.Message);
}

Console.WriteLine("\nPress any key to exit...");
Console.ReadKey();
}
}
}
62 changes: 62 additions & 0 deletions samples/Net10Client/SampleService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using Models;
using System.Xml.Linq;

namespace Net10Client
{
public class SampleService : ISampleService
{
public string Ping(string s)
{
Console.WriteLine("NET 10 Server - Exec ping method");
return $"NET 10 Response: {s}";
}

public ComplexModelResponse PingComplexModel(ComplexModelInput inputModel)
{
Console.WriteLine("NET 10 Server - Input data. IntProperty: {0}, StringProperty: {1}",
inputModel.IntProperty, inputModel.StringProperty);

return new ComplexModelResponse
{
FloatProperty = float.MaxValue / 2,
StringProperty = inputModel.StringProperty,
ListProperty = inputModel.ListProperty,
DateTimeOffsetProperty = inputModel.DateTimeOffsetProperty
};
}

public int[] IntArray()
{
return new int[] { 123, 456, 789 };
}

public void VoidMethod(out string s)
{
s = "Value from NET 10 server";
}

public Task<int> AsyncMethod()
{
return Task.FromResult(42);
}

public int? NullableMethod(bool? arg)
{
return null;
}

public void XmlMethod(XElement xml)
{
Console.WriteLine("NET 10 Server - XML: {0}", xml);
}

public ComplexReturnModel[] ComplexReturnModel()
{
return new ComplexReturnModel[]
{
new ComplexReturnModel { Id = 1, Name = "NET 10 Item 1" },
new ComplexReturnModel { Id = 2, Name = "NET 10 Item 2" }
};
}
}
}
53 changes: 53 additions & 0 deletions samples/Net10Sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# .NET 10 SoapCore Sample

This sample demonstrates how to use SoapCore with .NET 10, showcasing both a SOAP server and client implementation.

## Projects

### Net10Server
A .NET 10 web application that hosts a SOAP service using SoapCore.

- **Port**: 5060
- **Endpoints**:
- `/Service.svc` - DataContractSerializer endpoint
- `/Service.asmx` - XmlSerializer endpoint

### Net10Client
A .NET 10 console application that consumes the SOAP service.

## Running the Sample

1. **Start the Server**:
```bash
cd Net10Server
dotnet run
```

2. **Run the Client** (in a separate terminal):
```bash
cd Net10Client
dotnet run
```

## Features Demonstrated

- Basic string operations (Ping)
- Complex model serialization/deserialization
- Void methods with out parameters
- Async methods
- XML element handling
- Array return types
- Nullable types

## Key Differences from Previous Samples

- Uses modern .NET 10 hosting model with `IHostBuilder`
- Updated to use System.ServiceModel 8.0.* packages for better .NET 10 compatibility
- Demonstrates implicit usings and nullable reference types
- Uses a different port (5060) to avoid conflicts with other sample projects

## Requirements

- .NET 10 SDK
- SoapCore library
- Models project (shared across all samples)
13 changes: 13 additions & 0 deletions samples/Net10Server/Net10Server.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\SoapCore\SoapCore.csproj" />
<ProjectReference Include="..\Models\Models.csproj" />
</ItemGroup>

</Project>
27 changes: 27 additions & 0 deletions samples/Net10Server/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace Net10Server
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseUrls("http://*:5060");
})
.ConfigureLogging(logging =>
{
logging.AddDebug();
logging.AddConsole();
});
}
}
12 changes: 12 additions & 0 deletions samples/Net10Server/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"Net10Server": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5060"
}
}
}
63 changes: 63 additions & 0 deletions samples/Net10Server/SampleService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Models;
using System;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace Net10Server
{
public class SampleService : ISampleService
{
public string Ping(string s)
{
Console.WriteLine("NET 10 Server - Exec ping method");
return $"NET 10 Response: {s}";
}

public ComplexModelResponse PingComplexModel(ComplexModelInput inputModel)
{
Console.WriteLine("NET 10 Server - Input data. IntProperty: {0}, StringProperty: {1}",
inputModel.IntProperty, inputModel.StringProperty);

return new ComplexModelResponse
{
FloatProperty = float.MaxValue / 2,
StringProperty = inputModel.StringProperty,
ListProperty = inputModel.ListProperty,
DateTimeOffsetProperty = inputModel.DateTimeOffsetProperty
};
}

public int[] IntArray()
{
return [123, 456, 789];
}

public void VoidMethod(out string s)
{
s = "Value from NET 10 server";
}

public Task<int> AsyncMethod()
{
return Task.FromResult(42);
}

public int? NullableMethod(bool? arg)
{
return null;
}

public void XmlMethod(XElement xml)
{
Console.WriteLine("NET 10 Server - XML: {0}", xml);
}

public ComplexReturnModel[] ComplexReturnModel()
{
return [
new ComplexReturnModel { Id = 1, Name = "NET 10 Item 1" },
new ComplexReturnModel { Id = 2, Name = "NET 10 Item 2" }
];
}
}
}
Loading