Path: redb-route/tests/redb.Route.Tests.Soap/SoapHeaderPlaneTests.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.Soap/SoapHeaderPlaneTests.cs
----
using System.Net;
using System.Net.Sockets;
using AwesomeAssertions;
using redb.Route.Abstractions;
using redb.Route.Core;
using redb.Route.Soap;
using SoapDsl = redb.Route.Soap.Fluent.Soap;
namespace redb.Route.Tests.Soap;
/// The two header planes — envelope <soap:Header> vs transport — round-trip.
public class SoapHeaderPlaneTests
{
private static int FreePort() => global::redb.Route.Tests.Shared.TestPorts.Next();
[Fact]
public async Task EnvelopeHeader_And_Operation_ReachTheRoute()
{
var port = FreePort();
string? gotHeaderTo = null;
string? gotOperation = null;
await using var ctx = new RouteContext();
ctx.AddComponent(new SoapComponent());
ctx.AddRoutes(r =>
{
r.From(SoapDsl.Listen("/svc").Host("127.0.0.1").Port(port))
.Process(e =>
{
gotHeaderTo = e.In.GetHeader(SoapHeaders.HeaderPrefix + "To");
gotOperation = e.In.GetHeader(SoapHeaders.Operation);
e.In.Body = "ok";
});
r.From("direct://call")
.SetHeader(SoapHeaders.HeaderPrefix + "To", "svc")
.To(SoapDsl.Call($"http://127.0.0.1:{port}/svc"));
});
await ctx.Start();
var producer = ctx.GetEndpoint("direct://call").CreateProducer();
await producer.Start();
await producer.Process(new Exchange(new Message("1")));
gotHeaderTo.Should().NotBeNull().And.Contain("svc"); // envelope header plane crossed the wire
gotOperation.Should().Be("Ping"); // operation = body root element
}
}