title: Return DataTable schema beside data, in web service output
body: <p>I write a web service using c# and it going to be consumed in a java application.</p>
  
  <p>Simply I return a <code>Dataset</code> that has one or more <code>DataTable</code> in it. Output is in XML format.</p>
  
  <p>Now the consumer need to have the schema of the output table to know the table and field names.</p>
  
  <p>this is the webmethod:</p>
  
  <pre><code>[WebMethod]
  public DataSet GetWorkTypes(string UserName, string Password)
  {
      DataSet ds = new DataSet("CNIS");
      try
      {
          if (User Pass is Correct)
          {
              SqlDataAdapter adapter = new SqlDataAdapter("some query", "connectionString");
              adapter.Fill(ds, "theTable");
              return ds;
          }
          else
          {
              ds.Tables.Add("theTable");
              ds.Tables["theTable"].Columns.Add("Error");
              ds.Tables[0].Rows.Add("Wrong User Pass!");
              return ds;
          }
      }
      catch (Exception ex)
      {
          ds.Tables.Add("theTable");
          ds.Tables["theTable"].Columns.Add("Error");
          ds.Tables[0].Rows.Add(ex.Message);
          return ds;
      }
  }
  </code></pre>
  
  <p>How do I change my code to do that? </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I expect the different output than this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"&gt;
    &lt;soap12:Body&gt;
      &lt;GetWorkTypesResponse xmlns="http://cnis/"&gt;
        &lt;GetWorkTypesResult&gt;
          &lt;xsd:schema&gt;schema&lt;/xsd:schema&gt;xml&lt;/GetWorkTypesResult&gt;
      &lt;/GetWorkTypesResponse&gt;
    &lt;/soap12:Body&gt;
  &lt;/soap12:Envelope&gt;
  </code></pre>
  
  <p>I need something to be more descriptive.</p>