title: WCF CreateMessage from custom body xml
body: <p>I have the following code:</p>
  
  <pre><code>string body = "&lt;custom xml&gt;";
  
  XDocument doc = XDocument.Parse(body);
  
  MemoryStream stream = new MemoryStream();
  XmlWriter writer = XmlWriter.Create(stream);
  if (writer != null)
  {
    doc.Save(writer);
    writer.Flush();
    writer.Close();
  }
  
  stream.Position = 0;
  XmlReader rd = XmlReader.Create(stream);
  
  Message output = Message.CreateMessage(msg.Version, msg.Headers.Action, rd);
  output.Headers.CopyHeadersFrom(msg);
  output.Properties.CopyProperties(msg.Properties);
  </code></pre>
  
  <p>When I try to use the message I get the following error:</p>
  
  <blockquote>
    <p>hexadecimal value 0x02, is an invalid character. Line 1, position 2.</p>
  </blockquote>
  
  <p>Any idea why? And what I can do to fix this?</p>