title: Why does WCF wrap request/response types in another XML element, and how to prevent this?
body: <p>I have a simple echo service where I've defined one operation method and a pair of types for request/response:</p>
  
  <pre><code>[ServiceContract(Name = "EchoService", 
                   Namespace = "http://example.com/services", 
                   SessionMode = SessionMode.NotAllowed)]
  public interface IEchoService
  {
      [OperationContract(IsOneWay = false,
                         Action = "http://example.com/services/EchoService/Echo", 
                         ReplyAction = "http://example.com/services/EchoService/EchoResponse")]
      EchoResponse Echo(EchoRequest value);
  }
  </code></pre>
  
  <p>The data types:</p>
  
  <pre><code>[Serializable]
  [DataContract(Namespace = "http://example.com/services/EchoService", 
                Name = "EchoRequest")]
  public class EchoRequest
  {
      public EchoRequest() { }
  
      public EchoRequest(String value)
      {
          Value = value;
      }
  
      [DataMember]
      public String Value { get; set; }
  }
  
  [Serializable]
  [DataContract(Namespace = "http://example.com/services/EchoService", 
                Name = "EchoResponse")]
  public class EchoResponse
  {
      public EchoResponse() { }
  
      public EchoResponse(String value)
      {
          Value = value;
      }
  
      [DataMember]
      public String Value { get; set; }
  }
  </code></pre>
  
  <p>Invoking Message.CreateMessage() on an instance of EchoRequest yields:</p>
  
  <pre><code>  &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;s:Header /&gt;
      &lt;s:Body&gt;
        &lt;EchoRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://example.com/services/EchoService"&gt;
          &lt;Value&gt;hello, world!&lt;/Value&gt;
        &lt;/EchoRequest&gt;
      &lt;/s:Body&gt;
    &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>...which is exactly what I want. However, it appears that the service is expecting the message body to be further wrapped in another XML element, like this:</p>
  
  <pre><code>  &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;s:Header /&gt;
      &lt;s:Body&gt;
        &lt;Echo xmlns="http://example.com/services"&gt;
          &lt;EchoRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://example.com/services/EchoService"&gt;
            &lt;Value&gt;hello, world!&lt;/Value&gt;
          &lt;/EchoRequest&gt;
        &lt;/Echo&gt;
      &lt;/s:Body&gt;
    &lt;/s:Envelope&gt;
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  Thanks to Mark's reply, I've explored MessageContract instead of DataContract on the request/response types. This seems closer to what I want, but now it's going too far, and not expecting the outer type element, "EchoRequest".</p>
  
  <p>This is confusing since somehow Message.CreateMessage appears to unfailingly produce the correct XML, so it's apparently using some default serialization which I'd like to configure the service to accept. Am I just misunderstanding how Message.CreateMessage works?</p>