Applying XmlArrayAttribute to the return value that returns an array of complex objects???

Discussion in 'ASP .Net Web Services' started by Bob Rock, Jun 4, 2004.

  1. Bob Rock

    Bob Rock Guest

    Hello,

    I read that XmlArrayAttribute may be applyed to "the return value that
    returns an array of complex objects" but I don't understand how.
    I'd like it to apply it to a method returning an array of objects of a
    custom class. How can this be achieved???


    Bob Rock
     
    Bob Rock, Jun 4, 2004
    #1
    1. Advertising

  2. Use [return:XmlArray] and [return:XmlArrayItem] on the return type to get it
    to behave the way you want.

    [WebMethod(Description="Returns an ArrayList, using XmlArrayItem to type
    the members. This works. ")]
    [return:System.Xml.Serialization.XmlArray(ElementName="MyCollection",
    Namespace="http://something.org/2003/10/types")]
    [return: System.Xml.Serialization.XmlArrayItem(ElementName="Emp",
    Type=typeof(CEmployee))]
    [return: System.Xml.Serialization.XmlArrayItem(ElementName="Mgr",
    Type=typeof(CDeptManager))]
    [return: System.Xml.Serialization.XmlArrayItem(ElementName="Exec",
    Type=typeof(CExecutive))]
    [return:
    System.Xml.Serialization.XmlRoot("TypedList",
    Namespace="http://something.org/2003/10/types")
    ]
    public System.Collections.ArrayList GetList_ArrayList_TypedArray()
    {
    .....
    return whatever;
    }



    But, I think if you include an item in the ArrayList that is not included in
    the list of [return:XmlArrayItem(...)] attributes, you'll get a runtime
    error. To avoid this, you need to include a typeof(Object), which is like a
    catch-all.

    -Dino



    "Bob Rock" <> wrote in message
    news:...
    > Hello,
    >
    > I read that XmlArrayAttribute may be applyed to "the return value that
    > returns an array of complex objects" but I don't understand how.
    > I'd like it to apply it to a method returning an array of objects of a
    > custom class. How can this be achieved???
    >
    >
    > Bob Rock
    >
    >
     
    Dino Chiesa [Microsoft], Jun 8, 2004
    #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. Greenhorn
    Replies:
    15
    Views:
    833
    Keith Thompson
    Mar 6, 2005
  2. Replies:
    4
    Views:
    315
    Marcus Kwok
    Jun 1, 2006
  3. Fredy Villa

    Complex type as a return value

    Fredy Villa, Nov 5, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    117
    Fredy Villa
    Nov 5, 2003
  4. Srijayanth Sridhar
    Replies:
    19
    Views:
    627
    David A. Black
    Jul 2, 2008
  5. philjhanna
    Replies:
    0
    Views:
    110
    philjhanna
    Aug 5, 2005
Loading...

Share This Page