private static void CompareSampleMessage(Message message) { MemoryStream ms = new MemoryStream(); XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(ms); message.WriteBodyContents(writer); writer.Flush(); ms.Position = 0; XmlDictionaryReader xmlDictionaryReader = XmlDictionaryReader.CreateBinaryReader(ms, XmlDictionaryReaderQuotas.Max); XDocument xDoc = XDocument.Load(xmlDictionaryReader); string expectedMessageBody = @"<MessageRoot> <QueryOptions> <QueryOption Name=""where"" Value=""(it.City.StartsWith("R")&&(it.AddressID<400))""></QueryOption> <QueryOption Name=""orderby"" Value=""it.AddressId""></QueryOption> <QueryOption Name=""includeTotalCount"" Value=""true""></QueryOption> </QueryOptions> <GetCustomers xmlns=""http://tempuri.org/""> <name>TestName</name> </GetCustomers> </MessageRoot>"; Assert.AreEqual(expectedMessageBody, xDoc.ToString()); }