still having problem return arraylist of objects in webservice....

Discussion in 'ASP .Net Web Services' started by Milsnips, Sep 6, 2004.

  1. Milsnips

    Milsnips Guest

    hi there,

    i have a webservice which my function calls a database( eg. customer table),
    what i have is my own Customer class, and i want to return an array of my
    "Customer" objects.

    here is my code i use (c.GetList returns an arraylist of customer objects
    from the database:


    <WebMethod()> _
    Function GetClientList() As <XmlElement(GetType(getAway.Client))> ArrayList
    Dim c As New getAway.Client
    Dim a As ArrayList = c.GetList(False)
    Return a
    End Function

    i still get the same error below:

    System.InvalidOperationException: There was an error generating the XML
    document. ---> System.InvalidOperationException: The type getAway.Client was
    not expected. Use the XmlInclude or SoapInclude attribute to specify types
    that are not known statically.

    any help appreciated...

    Paul.
     
    Milsnips, Sep 6, 2004
    #1
    1. Advertising

  2. use XmlInclude or
    XmlArray and XmlArrayItem attributes to specify that type. eg


    <XmlArrayItem(ElementName := "item", Type:= GetType(getAway.Client)) , _
    XmlArray(ElementName := "stuff")> _


    "Milsnips" <> wrote in message
    news:u8sy55$...
    > hi there,
    >
    > i have a webservice which my function calls a database( eg. customer

    table),
    > what i have is my own Customer class, and i want to return an array of my
    > "Customer" objects.
    >
    > here is my code i use (c.GetList returns an arraylist of customer objects
    > from the database:
    >
    >
    > <WebMethod()> _
    > Function GetClientList() As <XmlElement(GetType(getAway.Client))>

    ArrayList
    > Dim c As New getAway.Client
    > Dim a As ArrayList = c.GetList(False)
    > Return a
    > End Function
    >
    > i still get the same error below:
    >
    > System.InvalidOperationException: There was an error generating the XML
    > document. ---> System.InvalidOperationException: The type getAway.Client

    was
    > not expected. Use the XmlInclude or SoapInclude attribute to specify types
    > that are not known statically.
    >
    > any help appreciated...
    >
    > Paul.
    >
    >
     
    Dino Chiesa [Microsoft], Sep 7, 2004
    #2
    1. Advertising

  3. Milsnips

    Surya Yadav Guest

    I am ruuning into a similar problem. Even XmlInclude does
    not seem to work.
    My webservice method ( calls Author.GetAuthors() to build
    and return an IList of authors.
    The webservice method is defined as:
    [WebMethod]
    public IList GetAllAuthors()
    {
    Author author=new Author();
    return author.GetAuthors();
    The Author class is defined in a separate class library
    called AuthPubsDAL. Author.GetAuthors() is defined as
    public IList GetAuthors()
    {
    ...}
    which accesses the pubs database and builds an arraylist
    of author objects.

    I added [XmlInclude (typeof(Author))] to the webservice
    class, to the Author class and to the WebMethod
    GetAllAuthors() which is part of the webservice class
    with no luck. I am not sure as to what's the proper use
    of XmlInclude and where it should be added. Please help.

    Surya

    >-----Original Message-----
    >use XmlInclude or
    >XmlArray and XmlArrayItem attributes to specify that

    type. eg
    >
    >
    > <XmlArrayItem(ElementName := "item", Type:= GetType

    (getAway.Client)) , _
    > XmlArray(ElementName := "stuff")> _
    >
    >
    >"Milsnips" <> wrote in message
    >news:u8sy55$...
    >> hi there,
    >>
    >> i have a webservice which my function calls a database

    ( eg. customer
    >table),
    >> what i have is my own Customer class, and i want to

    return an array of my
    >> "Customer" objects.
    >>
    >> here is my code i use (c.GetList returns an arraylist

    of customer objects
    >> from the database:
    >>
    >>
    >> <WebMethod()> _
    >> Function GetClientList() As <XmlElement(GetType

    (getAway.Client))>
    >ArrayList
    >> Dim c As New getAway.Client
    >> Dim a As ArrayList = c.GetList(False)
    >> Return a
    >> End Function
    >>
    >> i still get the same error below:
    >>
    >> System.InvalidOperationException: There was an error

    generating the XML
    >> document. ---> System.InvalidOperationException: The

    type getAway.Client
    >was
    >> not expected. Use the XmlInclude or SoapInclude

    attribute to specify types
    >> that are not known statically.
    >>
    >> any help appreciated...
    >>
    >> Paul.
    >>
    >>

    >
    >
    >.
    >
     
    Surya Yadav, Sep 26, 2004
    #3
    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. Saravanan Rathinavelu

    Iterate through ArrayList using an another ArrayList

    Saravanan Rathinavelu, Aug 16, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    2,748
    Natty Gur
    Aug 19, 2003
  2. Kaidi
    Replies:
    4
    Views:
    2,396
    Kaidi
    Jan 3, 2004
  3. Marcus

    Still having Link-Problem

    Marcus, May 14, 2007, in forum: HTML
    Replies:
    1
    Views:
    371
    Neredbojias
    May 14, 2007
  4. xz
    Replies:
    16
    Views:
    2,390
  5. Philipp
    Replies:
    6
    Views:
    932
    Arne Vajhøj
    May 28, 2008
Loading...

Share This Page