Web Service Factory: Creating a schema for a System.Collections.Generic.List<customer>

Discussion in 'ASP .Net Web Services' started by Henrik Skak Pedersen, Dec 13, 2006.

  1. Hi,

    I have created a xsd file with a element called Customer. When I then select
    "Create data types from schema" a customer class is being generated. But how
    do I handle a list of customers? In code I would of course like to use a
    generic list, but how does that fit into the factory?

    Is it a problem that the List not is a part of the schema?

    I guess that I can't use it in the factory wizards?

    Thanks
    Henrik.
     
    Henrik Skak Pedersen, Dec 13, 2006
    #1
    1. Advertising

  2. Hello Henrik,

    As for the "Create data types from schema", are you using the xsd.exe
    utility or any other component to generate the class from XSD schema?

    For Genericic List<xxx> type of any other Array/List based types, .net
    webservice or XML seriailation will use the following like XML Array
    element to map them(the "ArrayOfCustomer" element):

    ================
    <xs:schema elementFormDefault="qualified"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="ArrayOfCustomer" nillable="true" type="ArrayOfCustomer"
    />
    <xs:complexType name="ArrayOfCustomer">
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="unbounded" name="Customer"
    nillable="true" type="Customer" />
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="Customer">
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1" name="FirstName"
    type="xs:string" />
    <xs:element minOccurs="0" maxOccurs="1" name="LastName"
    type="xs:string" />
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    ===================

    Actually, such class as Generic List<> , ArrayList, custom Collection are
    all .net specific, XML/XSD schemea does not have so specific definiation
    for them. and it can only use a xml array or custom elemetn with sequential
    elements to represent them.

    Hope this helps.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Dec 14, 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. Medi Montaseri
    Replies:
    17
    Views:
    895
    Medi Montaseri
    Sep 3, 2003
  2. Polaris431
    Replies:
    2
    Views:
    491
    Chris Dollin
    Nov 9, 2006
  3. Kuldeep

    System.Collections.Generic.List

    Kuldeep, Mar 27, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    523
    Cowboy \(Gregory A. Beamer\)
    Mar 27, 2007
  4. Monty
    Replies:
    3
    Views:
    1,836
    Walter Wang [MSFT]
    Nov 6, 2007
  5. C#
    Replies:
    4
    Views:
    421
Loading...

Share This Page