title: How to Declare Complex Nested C# Type for Web Service
body: <p>I would like to create a service that accepts a complex nested type.  In a sample asmx file I created:</p>
  
  <pre>
  [WebService(Namespace = "http://tempuri.org/")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
  // [System.Web.Script.Services.ScriptService]
  public class ServiceNest : System.Web.Services.WebService
  {
     public class Block
     {
        [XmlElement(IsNullable = false)]
        public int number;
     }
  
     public class Cell
     {
        [XmlElement(IsNullable = false)]
        public Block block;
     }
  
     public class Head
     {
        [XmlElement(IsNullable = false)]
        public Cell cell;
     }
  
     public class Nest
     {
        public Head head;
     }
  
     [WebMethod]
     public void TakeNest(Nest nest)
     {
     }
  
  }
  </pre>
  
  <p>When I view the asmx file in IE the test page shows the example SOAP post request as:</p>
  
  <pre>
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soap:Body&gt;
      &lt;TakeNest xmlns="http://schemas.intellicorp.com/livecompare/"&gt;
        &lt;nest&gt;
          &lt;head&gt;
            &lt;cell&gt;
              &lt;block xsi:nil="true" /&gt;
            &lt;/cell&gt;
          &lt;/head&gt;
        &lt;/nest&gt;
      &lt;/TakeNest&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;</pre>
  
  <p>It hasn't expanded the &lt;block&gt; into its number member.</p>
  
  <p>Looking at the WSDL, the types all look good.  So is this just a limitation of the post demo page creator?</p>
  
  <p>Thanks.</p>