Receiving arbitary 2-dimensional tables in a WebService method

Discussion in 'ASP .Net Web Services' started by George Vlahakis, Jun 27, 2006.

  1. To put simply:

    I have a WebMethod I wish to be able to accept arbitary two-dimensional
    tables generated from any client (not .NET only). I have in fact gone down
    the path of creating a custom "ImportRequest" class which in effect has some
    header information and then follows with the columns and rows of the table
    that needs to be imported.

    I do not need the table to conform to any specific schema as the database
    table will be created on the fly, but I DO need to know the types for each
    column. I thought of using some sort of enumeration for describe the type
    but everytime I look at the issue again I keep getting the feeling I am
    re-inventing the wheel.

    It would be good if in my "ImportRequest" I could somehow have the type
    embedded so that a table lets say :

    <Counsil>
    <Name>
    Berkshire
    </Name>
    <Population>
    89,098
    </Population>
    <SurveyDate>
    01/01/2006
    </SurveyDate>
    </Council>

    so I could (on the receiving side) determine that <Population> is a numeric
    and that <SurveyDate> is a date.

    Here is a sample of what I wish to do:

    <WebMethod> Public Function ImportData( request As ImportRequest ) as
    ImportResponse
    ...
    End Function

    Public Class ImportRequest
    Public CustomerID As Long
    Public Name As String
    Public Description As String
    Public Columns() As Column
    Public Rows() As Row
    End Class

    Public Enum ColumnType
    Text
    Numeric
    End Enum

    Public Class Column
    Public ColumnName As String
    Public ColumnType As ColumnType
    End Class

    Public Class Row
    Public Values() As String
    End Class

    The goal is to receive the "Values" and convert them to a specified type. I
    tried using the DataSet and it also consumed XML with String types for
    everything unless I used a Schema on the client side. The later I suspect
    will be a bit too much to ask from the client to do so I am hoping that the
    Value types can somehow be embedded in the XML ImportRequest.

    Thanks in advance

    George
     
    George Vlahakis, Jun 27, 2006
    #1
    1. Advertising

  2. George Vlahakis

    Dale Guest

    You could return objects that contain the value as an object and the name of
    the type of the value as a string. You would still have to use a class
    factory or at least a case statement on the client to get the right type but
    at least you'd know what type was returned.

    To return objects from your webservice, look at my series at
    http://www.dalepreston.com/Blog/2005/02/returning-custom-classes-from-web.html

    HTH

    Dale
    --
    Dale Preston
    MCAD C#
    MCSE, MCDBA


    "George Vlahakis" wrote:

    > To put simply:
    >
    > I have a WebMethod I wish to be able to accept arbitary two-dimensional
    > tables generated from any client (not .NET only). I have in fact gone down
    > the path of creating a custom "ImportRequest" class which in effect has some
    > header information and then follows with the columns and rows of the table
    > that needs to be imported.
    >
    > I do not need the table to conform to any specific schema as the database
    > table will be created on the fly, but I DO need to know the types for each
    > column. I thought of using some sort of enumeration for describe the type
    > but everytime I look at the issue again I keep getting the feeling I am
    > re-inventing the wheel.
    >
    > It would be good if in my "ImportRequest" I could somehow have the type
    > embedded so that a table lets say :
    >
    > <Counsil>
    > <Name>
    > Berkshire
    > </Name>
    > <Population>
    > 89,098
    > </Population>
    > <SurveyDate>
    > 01/01/2006
    > </SurveyDate>
    > </Council>
    >
    > so I could (on the receiving side) determine that <Population> is a numeric
    > and that <SurveyDate> is a date.
    >
    > Here is a sample of what I wish to do:
    >
    > <WebMethod> Public Function ImportData( request As ImportRequest ) as
    > ImportResponse
    > ...
    > End Function
    >
    > Public Class ImportRequest
    > Public CustomerID As Long
    > Public Name As String
    > Public Description As String
    > Public Columns() As Column
    > Public Rows() As Row
    > End Class
    >
    > Public Enum ColumnType
    > Text
    > Numeric
    > End Enum
    >
    > Public Class Column
    > Public ColumnName As String
    > Public ColumnType As ColumnType
    > End Class
    >
    > Public Class Row
    > Public Values() As String
    > End Class
    >
    > The goal is to receive the "Values" and convert them to a specified type. I
    > tried using the DataSet and it also consumed XML with String types for
    > everything unless I used a Schema on the client side. The later I suspect
    > will be a bit too much to ask from the client to do so I am hoping that the
    > Value types can somehow be embedded in the XML ImportRequest.
    >
    > Thanks in advance
    >
    > George
    >
    >
    >
     
    Dale, Jul 8, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alf P. Steinbach
    Replies:
    0
    Views:
    439
    Alf P. Steinbach
    Aug 18, 2003
  2. John Harrison
    Replies:
    4
    Views:
    6,931
    Default User
    Aug 19, 2003
  3. John Smith

    Arbitary VTABLE/Python

    John Smith, Apr 15, 2004, in forum: Python
    Replies:
    2
    Views:
    467
    Your name
    May 4, 2004
  4. Aryeh M. Friedman

    Getting an arbitary date the *RIGHT* way

    Aryeh M. Friedman, Jan 21, 2009, in forum: Java
    Replies:
    6
    Views:
    364
    Roedy Green
    Jan 23, 2009
  5. Aryeh M. Frierdman

    Freezing an arbitary object

    Aryeh M. Frierdman, Jul 6, 2003, in forum: Ruby
    Replies:
    8
    Views:
    129
    Robert Klemme
    Jul 7, 2003
Loading...

Share This Page