Beispiel #1
0
 public static XmlReader GetXmlReaderAtWebBodyContents(this System.ServiceModel.Channels.Message message)
 {
     // see https://blogs.msdn.microsoft.com/endpoint/2011/04/23/wcf-extensibility-message-inspectors/,
     return(message.GetWebContentFormat() switch {
         // see https://docs.microsoft.com/en-us/archive/blogs/endpoint/wcf-extensibility-message-inspectors, MessageToString
         WebContentFormat.Default or WebContentFormat.Xml => message.GetReaderAtBodyContents(),
         WebContentFormat.Raw => message.GetXmlReaderAtRawBodyContents(),
         var format => throw new ArgumentException(
             $"Unsupported {nameof(WebContentFormat)}.'{format}' message, only {WebContentFormat.Raw} and {WebContentFormat.Xml} are supported.",
             nameof(message))
     });