title: How do I use a custom Class to Return data from a web service
body: <p>So I have an application that uses a webservice, On the UI side the user picks a table which sends a request across the web to my webservice to return the fields of this table. </p>
  
  <p>So after this request is accomplished I have, on the webservice side a series of Name,Type Pairs that I need to serialize and send back to my client. I could use a List(of String()) to send the values back but I want to use a List(of Custom_Class) instead because later I have to do this on a much larger scale and I want to learn on this simpler version.</p>
  
  <p>Now I know from my research that I can create a class from an .XSD document so what I'm thinking I should do is convert this class into a .XSD and somehow send that with my request to the WebService so that it can use that .XSD to create a class dynamically at runtime, instantiate that class into objects, fill those objects with the result set, bundle it into a strongly typed List(of ReturnFields), serialize that into XML, send it back to my client, Deserialize it back and display it for him.</p>
  
  <p>So 2 questions:
  1. Am I on the right track here or am I going about this all the wrong way.
  2. How do I pass the .XSD schema to my Webservice so it can use it to create the class on the server side?</p>
  
  <hr>
  
  <p>--------------EDIT-----------
  So based on pMartin's input I'm revising this question a bit.</p>
  
  <p>So below is my code as it stands now.</p>
  
  <p>I have a "Fields" Class Living on my Library Layer</p>
  
  <pre><code>Public Class Fields
      Private Field_Name As String
      Private Field_Type As System.Type
  
      Public Sub New()
      End Sub
  
      Protected Overrides Sub Finalize()
      End Sub
  
      Property Name() As String
          Get
              Return Field_Name
          End Get
          Set(ByVal value As String)
              Field_Name = value
          End Set
      End Property
  
      Property Type() As System.Type
          Get
              Return Field_Type
          End Get
          Set(ByVal value As System.Type)
              Field_Type = value
          End Set
      End Property
  End Class
  </code></pre>
  
  <p>This get's used in my library by the following code.</p>
  
  <pre><code>Public Function Get_List_Of_Fields(ByVal Table_Name As String, ByVal Database_Name As String) As List(Of Fields)
      Dim List_Of_Fields As New List(Of Fields)
      Dim DataModel As MetaModel = Get_Datamodel(Database_Name)
  
      Dim Data_Table = (From DataTable In DataModel.GetTables Where DataTable.TableName = Table_Name).FirstOrDefault
  
      For Each Field In Data_Table.RowType.DataMembers
          Dim Fields_Obj As New Fields
          Fields_Obj.Name = Field.Name
          Fields_Obj.Type = Field.Type
          List_Of_Fields.Add(Fields_Obj)
      Next
      Return List_Of_Fields
  End Function
  </code></pre>
  
  <p>Which Returns to my Webservice (.ASMX)</p>
  
  <pre><code>&lt;WebMethod()&gt; _
  Public Function Get_List_of_Fields(ByVal Table_Name As String, ByVal Database_Name As String) As List(Of Fields)
      Return _DynaLib.Get_List_Of_Fields(Table_Name, Database_Name)
  End Function
  </code></pre>
  
  <p>Which returns to my Client
  'This is where my error is on this "return" line</p>
  
  <pre><code>Imports Dynamic_Charting.DynamicReference 
  Private _DynamicService As New DynamicServiceSoapClient
  
  Public Function Get_List_of_Fields(ByVal Table_name As String, ByVal Database_Name As String) As List(Of Fields)
       Return _DynamicService.Get_List_of_Fields(Table_name, Database_Name)
   End Function
  </code></pre>
  
  <p>It is here that I have my error. I get the following Error.</p>
  
  <p>Error   11<br>
  Value of type '1-dimensional array of Dynamic_Charting.DynamicReference.Fields' cannot be converted to 
  'System.Collections.Generic.List(Of Dynamic_Charting.DynamicReference.Fields)'. </p>