I am migrating a WCF client application from DotNet Framework to DotNet (Core) 7. The object I am using serializes using ASCII character 0x07 as a separator, which under DotNet Framework would be escaped to .
var request = new Request(...);
Message wcfMessage = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "MyServiceAction", request);
var wcfMessageXml = wcfMessage.ToString();
Under dotnet framework, this results in a WCF body that looks like <SerializedData>Field 1Field 2Etc<SerializedData>.
However, using the same code in dotnet core, I am getting: System.ArgumentException : '\a', hexadecimal value 0x07, is an invalid character.
I've tracked this down to the fact that in the latest dotnet, the XmlReader, XmlWriter, and related classes will try to unescape any escape sequences in text, and then check whether the character is valid XML. If I were using those classes directly, I could use XmlReaderSetting/XmlWriterSettings.CheckCharacters = false to skip over this bad behavior, but I can't figure out how I can do the same with the WCF Message object. How can I get this to work?