title: Ignore the Envelope and Body in the SOAP XML parameter in WEB API (.NET CORE)
body: <p>I'm working on a Web API (.NET CORE 2.0), the API receives a SOAP based XML request. see below</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ns="http://example.com/ns"&gt;
     &lt;soapenv:Body&gt;
        &lt;ns:Customer&gt;
         &lt;ns:Id&gt;123&lt;/ns:Id&gt;
         &lt;ns:Name&gt;John Brown&lt;/ns:Name&gt;
        &lt;/ns:Customer&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>The above XML works fine, and accepted by the web api.</p>
  
  <p>Controller:</p>
  
  <pre><code>    [Route("api/Customer")]
      public class CustomerController : Controller
      {
          [Route("Detail")]
          [HttpPost]
          public IActionResult Detail([FromBody]Envelope request)
          {
              return Ok();
          }
      }
  </code></pre>
  
  <p>Request Object:</p>
  
  <pre><code> [XmlRoot(ElementName = "Envelope", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
  public class Envelope
  {
      [XmlElement(ElementName = "Body", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
      public Body Body { get; set; }
  }
  
  [XmlRoot(ElementName = "Body", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
  public class Body
  {
      [XmlElement(ElementName = "Customer", Namespace = "http://example.com/ns")]
      public Customer Customer { get; set; }
  }
  
  [XmlRoot(ElementName = "Customer", Namespace = "http://example.com/ns")]
  public class Customer
  {
      [XmlElement(ElementName = "Id", Namespace = "http://example.com/ns")]
      public string Id { get; set; }
  
      [XmlElement(ElementName = "Name", Namespace = "http://example.com/ns")]
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>The above code works fine, I would like to ask is there a better way to eliminate or remove the <code>Envelope</code> and <code>Body</code> class (decorated by XmlRoot and XmlElement)</p>
  
  <p>So we only accepts the objects that we wanted.
  It always requires me to create the Envelope and Body class everytime I create an object parameter just only to satisfy the SOAP xml.</p>
  
  <p>Controller would be look like this.</p>
  
  <pre><code>[Route("api/Customer")]
  public class CustomerController : Controller
  {
      [Route("Detail")]
      [HttpPost]
      public IActionResult Detail([FromBody]Customer request)
      {
          return Ok();
      }
  }
  </code></pre>
  
  <p>but still accepts the above XML.</p>