Path: redb-route/tests/redb.Route.Tests.Soap/SoapRealFormatTests.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/SoapRealFormatTests.cs
----
using AwesomeAssertions;
using redb.Route.Soap;
namespace redb.Route.Tests.Soap;
///
/// Offline interop (no vulnerable dependency): robustness against the wire formats real SOAP stacks
/// (WCF/CXF) actually emit — arbitrary namespace prefixes, WS-Addressing headers with mustUnderstand,
/// SOAP 1.2 faults. Our parser is namespace-driven, so prefixes must not matter. Live interop against an
/// independent stack (Java CXF in Docker) is the remaining net-gated step; see the plan.
///
public class SoapRealFormatTests
{
// A .NET WCF response: envelope prefix "s", WS-Addressing header with s:mustUnderstand, default-ns body.
private const string WcfStyle =
"" +
"" +
"urn:GetFares" +
"" +
"100" +
"";
// An Apache CXF response: prefix "soapenv", body element with its own prefix "ns1".
private const string CxfStyle =
"" +
"200" +
"";
[Fact]
public void Parses_WcfStyle_PrefixedEnvelope()
{
var parsed = SoapEnvelope.Parse(System.Text.Encoding.UTF8.GetBytes(WcfStyle), SoapVersion.Soap11);
parsed.IsFault.Should().BeFalse();
parsed.BodyXml.Should().Contain("GetFaresResponse").And.Contain("100");
}
[Fact]
public void Reads_WcfStyle_EnvelopeHeader_WithMustUnderstand()
{
var headers = SoapEnvelope.ReadHeaders(System.Text.Encoding.UTF8.GetBytes(WcfStyle), SoapVersion.Soap11).ToList();
headers.Should().ContainSingle();
headers[0].Name.LocalName.Should().Be("Action");
headers[0].Value.Should().Be("urn:GetFares");
}
[Fact]
public void Parses_CxfStyle_PrefixedBodyElement()
{
var parsed = SoapEnvelope.Parse(System.Text.Encoding.UTF8.GetBytes(CxfStyle), SoapVersion.Soap11);
parsed.IsFault.Should().BeFalse();
parsed.BodyXml.Should().Contain("getFaresResponse").And.Contain("200");
}
[Fact]
public void Parses_Soap12_Fault_FromRealShape()
{
const string fault12 =
"" +
"" +
"env:Sender" +
"Invalid fare request" +
"" +
"";
var parsed = SoapEnvelope.Parse(System.Text.Encoding.UTF8.GetBytes(fault12), SoapVersion.Soap12);
parsed.IsFault.Should().BeTrue();
parsed.FaultCode.Should().Be("env:Sender");
parsed.FaultString.Should().Be("Invalid fare request");
}
}