Path: redb-route/tests/redb.Route.Tests.Soap/SoapDataFormatTests.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/SoapDataFormatTests.cs ---- using System.Net; using System.Net.Sockets; using System.Xml.Serialization; 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; /// /// camel-cxf dataFormat parity: MESSAGE (whole-envelope transparent proxy) and POJO (typed request/response /// via XmlSerializer). PAYLOAD is covered by the loopback suite. /// public class SoapDataFormatTests { private static int FreePort() => global::redb.Route.Tests.Shared.TestPorts.Next(); [Fact] public async Task MessageDataFormat_PassesWholeEnvelopeBothWays() { var port = FreePort(); string? routeSawBody = null; await using var ctx = new RouteContext(); ctx.AddComponent(new SoapComponent()); ctx.AddToRegistry("msg", new SoapConnectionFactory { EndpointUrl = $"http://127.0.0.1:{port}/svc", DataFormat = SoapDataFormat.Message, }); ctx.AddRoutes(r => { r.From(SoapDsl.Listen("/svc").Host("127.0.0.1").Port(port).ConnectionFactory("msg")) .Process(e => { routeSawBody = e.In.Body!.ToString(); // Transparent proxy: the route replies with a whole envelope of its own. e.In.Body = "" + "42"; }); r.From("direct://call").To(SoapDsl.Call($"http://127.0.0.1:{port}/svc").ConnectionFactory("msg")); }); await ctx.Start(); var producer = ctx.GetEndpoint("direct://call").CreateProducer(); await producer.Start(); var exchange = new Exchange(new Message( "" + "")); await producer.Process(exchange); // The consumer saw the full inbound envelope, and the producer got the full reply envelope. routeSawBody.Should().Contain(" { r.From(SoapDsl.Listen("/svc").Host("127.0.0.1").Port(port).ConnectionFactory("server")) .Process(e => { var req = (GetFareRequest)e.In.Body!; gotRoute = req.Route; e.In.Body = new GetFareResponse { Price = 100 }; }); r.From("direct://call").To(SoapDsl.Call($"http://127.0.0.1:{port}/svc").ConnectionFactory("client")); }); await ctx.Start(); var producer = ctx.GetEndpoint("direct://call").CreateProducer(); await producer.Start(); var exchange = new Exchange(new Message(new GetFareRequest { Route = "JFK-LHR" })); await producer.Process(exchange); // The consumer received a typed request object; the producer got back a typed response object. gotRoute.Should().Be("JFK-LHR"); exchange.Out!.Body.Should().BeOfType().Which.Price.Should().Be(100); } }