Need help returning data from a vb.net webservice please

Discussion in 'ASP .Net Web Services' started by Molalla Attenborough, Dec 29, 2003.

  1. My task seems simple: I want to create a vb.net webservice and consume it
    with a client created in Macromedia FlashMX.

    Let's get this out of the way - I don't want to use Coldfusion for data access.
    I do not want to use vb.net to create my client interface. I want my service
    to return a plain old array of complex types.

    FlashMX doesn't work well with XML data serialized by returning a dataset
    object from a public function in the service.

    I have been trying to find a way to return the data from the service in a manner
    that Flash can utilize. I have made some headway but I need a little more help.

    Can anyone show me a way to return data from a vb.net webservice in a format
    that is serialzed as an array of complex types? I would really appreciate it.

    I don't need the code to fill datasets. I just need to know how to proceed from
    there.

    Thanks in advance!
    Molalla Attenborough, Dec 29, 2003
    #1
    1. Advertising

  2. Molalla Attenborough

    Jan Tielens Guest

    You can create a class to store date, for example suppose you want to
    retrieve Customer information:
    Public Class Customer
    Private _name As String
    Private _email As String

    Public Sub New(ByVal name As String, ByVal email As String)
    Me.Name = name
    Me.Email = email
    End Sub

    Public Property Name() As String
    Get
    Return _name
    End Get
    Set(ByVal value As String)
    _name = value
    End Set
    End Property


    Public Property Email() As String
    Get
    Return _email
    End Get
    Set(ByVal value As String)
    _email = value
    End Set
    End Property
    End Class

    In your Webservice you can return an array of customer objects:
    Dim a As New ArrayList

    a.Add(New Customer("jan", "111"))
    a.Add(New Customer("bill", "222"))

    Return a.ToArray(GetType(Customer))

    --
    Greetz,
    Jan
    __________________________________
    Read my weblog: http://weblogs.asp.net/jan
    "Molalla Attenborough" <> schreef in bericht
    news:%...
    > My task seems simple: I want to create a vb.net webservice and consume it
    > with a client created in Macromedia FlashMX.
    >
    > Let's get this out of the way - I don't want to use Coldfusion for data

    access.
    > I do not want to use vb.net to create my client interface. I want my

    service
    > to return a plain old array of complex types.
    >
    > FlashMX doesn't work well with XML data serialized by returning a dataset
    > object from a public function in the service.
    >
    > I have been trying to find a way to return the data from the service in a

    manner
    > that Flash can utilize. I have made some headway but I need a little more

    help.
    >
    > Can anyone show me a way to return data from a vb.net webservice in a

    format
    > that is serialzed as an array of complex types? I would really appreciate

    it.
    >
    > I don't need the code to fill datasets. I just need to know how to proceed

    from
    > there.
    >
    > Thanks in advance!
    >
    >
    Jan Tielens, Dec 29, 2003
    #2
    1. Advertising

  3. "Jan Tielens" <> wrote in message
    news:...
    > You can create a class to store date, for example suppose you want to
    > retrieve Customer information:
    > Public Class Customer
    > Private _name As String
    > Private _email As String
    >
    > Public Sub New(ByVal name As String, ByVal email As String)
    > Me.Name = name
    > Me.Email = email
    > End Sub
    >
    > Public Property Name() As String
    > Get
    > Return _name
    > End Get
    > Set(ByVal value As String)
    > _name = value
    > End Set
    > End Property
    >
    >
    > Public Property Email() As String
    > Get
    > Return _email
    > End Get
    > Set(ByVal value As String)
    > _email = value
    > End Set
    > End Property
    > End Class
    >
    > In your Webservice you can return an array of customer objects:
    > Dim a As New ArrayList
    >
    > a.Add(New Customer("jan", "111"))
    > a.Add(New Customer("bill", "222"))
    >
    > Return a.ToArray(GetType(Customer))
    >
    > --
    > Greetz,
    > Jan
    > __________________________________
    > Read my weblog: http://weblogs.asp.net/jan
    > "Molalla Attenborough" <> schreef in bericht
    > news:%...
    > > My task seems simple: I want to create a vb.net webservice and consume it
    > > with a client created in Macromedia FlashMX.
    > >
    > > Let's get this out of the way - I don't want to use Coldfusion for data

    > access.
    > > I do not want to use vb.net to create my client interface. I want my

    > service
    > > to return a plain old array of complex types.
    > >
    > > FlashMX doesn't work well with XML data serialized by returning a dataset
    > > object from a public function in the service.
    > >
    > > I have been trying to find a way to return the data from the service in a

    > manner
    > > that Flash can utilize. I have made some headway but I need a little more

    > help.
    > >
    > > Can anyone show me a way to return data from a vb.net webservice in a

    > format
    > > that is serialzed as an array of complex types? I would really appreciate

    > it.
    > >
    > > I don't need the code to fill datasets. I just need to know how to proceed

    > from
    > > there.
    > >
    > > Thanks in advance!


    This is about as close as I have been able to get. I have been working with the
    arraylist. the problem is that it causes the serializer to choke. I get error messages
    telling me to add XmlIncludes etc. It is the specifics and not the generalizations
    that I am stuck on. Your example causes the same problems for me.

    I appreciate your help. Do you know the proper syntax for declaring a Class
    with the correct xmlelement etc tags to get through the serializer?

    TIA
    Molalla Attenborough, Dec 29, 2003
    #3
  4. Molalla Attenborough

    Jan Tielens Guest

    The ArrayList is not strongly types, so it does not serialize well (without
    including the XMLInclude attributes). So it's better to return a strongly
    types list like an array. Did you try the return statement as in my example?
    Make sure you use the ToArray method.
    Return a.ToArray(GetType(Customer))

    If you really want to work with the ArrayList, let me know; I'll lookup the
    syntax and try to make a quick example...

    --
    Greetz,
    Jan
    __________________________________
    Read my weblog: http://weblogs.asp.net/jan
    "Molalla Attenborough" <> schreef in bericht
    news:...
    > "Jan Tielens" <> wrote in message
    > news:...
    > > You can create a class to store date, for example suppose you want to
    > > retrieve Customer information:
    > > Public Class Customer
    > > Private _name As String
    > > Private _email As String
    > >
    > > Public Sub New(ByVal name As String, ByVal email As String)
    > > Me.Name = name
    > > Me.Email = email
    > > End Sub
    > >
    > > Public Property Name() As String
    > > Get
    > > Return _name
    > > End Get
    > > Set(ByVal value As String)
    > > _name = value
    > > End Set
    > > End Property
    > >
    > >
    > > Public Property Email() As String
    > > Get
    > > Return _email
    > > End Get
    > > Set(ByVal value As String)
    > > _email = value
    > > End Set
    > > End Property
    > > End Class
    > >
    > > In your Webservice you can return an array of customer objects:
    > > Dim a As New ArrayList
    > >
    > > a.Add(New Customer("jan", "111"))
    > > a.Add(New Customer("bill", "222"))
    > >
    > > Return a.ToArray(GetType(Customer))
    > >
    > > --
    > > Greetz,
    > > Jan
    > > __________________________________
    > > Read my weblog: http://weblogs.asp.net/jan
    > > "Molalla Attenborough" <> schreef in bericht
    > > news:%...
    > > > My task seems simple: I want to create a vb.net webservice and consume

    it
    > > > with a client created in Macromedia FlashMX.
    > > >
    > > > Let's get this out of the way - I don't want to use Coldfusion for

    data
    > > access.
    > > > I do not want to use vb.net to create my client interface. I want my

    > > service
    > > > to return a plain old array of complex types.
    > > >
    > > > FlashMX doesn't work well with XML data serialized by returning a

    dataset
    > > > object from a public function in the service.
    > > >
    > > > I have been trying to find a way to return the data from the service

    in a
    > > manner
    > > > that Flash can utilize. I have made some headway but I need a little

    more
    > > help.
    > > >
    > > > Can anyone show me a way to return data from a vb.net webservice in a

    > > format
    > > > that is serialzed as an array of complex types? I would really

    appreciate
    > > it.
    > > >
    > > > I don't need the code to fill datasets. I just need to know how to

    proceed
    > > from
    > > > there.
    > > >
    > > > Thanks in advance!

    >
    > This is about as close as I have been able to get. I have been working

    with the
    > arraylist. the problem is that it causes the serializer to choke. I get

    error messages
    > telling me to add XmlIncludes etc. It is the specifics and not the

    generalizations
    > that I am stuck on. Your example causes the same problems for me.
    >
    > I appreciate your help. Do you know the proper syntax for declaring a

    Class
    > with the correct xmlelement etc tags to get through the serializer?
    >
    > TIA
    >
    >
    >
    Jan Tielens, Dec 29, 2003
    #4
  5. "Jan Tielens" <> wrote in message
    news:...
    > You can create a class to store date, for example suppose you want to
    > retrieve Customer information:
    > In your Webservice you can return an array of customer objects:
    > Dim a As New ArrayList
    >
    > a.Add(New Customer("jan", "111"))
    > a.Add(New Customer("bill", "222"))
    >
    > Return a.ToArray(GetType(Customer))
    >
    > --
    > Greetz,
    > Jan


    This is the part that I am stuck on.
    Do I return it as an array?
    As in:

    <WebMethod()> Public Function GetArray() as array
    Dim a As New ArrayList

    a.Add(New Customer("jan", "111"))
    a.Add(New Customer("bill", "222"))

    Return a.ToArray(GetType(Customer))

    I am getting an error when I try to do this that says
    You must implement a default accessor on system.array because it inherits from
    ICollection.

    I feel like I am close but I still can't get it to work.
    Molalla Attenborough, Dec 30, 2003
    #5
  6. "Molalla Attenborough" <> wrote in message
    news:...
    > "Jan Tielens" <> wrote in message
    > news:...
    > > You can create a class to store date, for example suppose you want to
    > > retrieve Customer information:
    > > In your Webservice you can return an array of customer objects:
    > > Dim a As New ArrayList
    > >
    > > a.Add(New Customer("jan", "111"))
    > > a.Add(New Customer("bill", "222"))
    > >
    > > Return a.ToArray(GetType(Customer))
    > >
    > > --
    > > Greetz,
    > > Jan

    >
    > This is the part that I am stuck on.
    > Do I return it as an array?
    > As in:
    >
    > <WebMethod()> Public Function GetArray() as array
    > Dim a As New ArrayList
    >
    > a.Add(New Customer("jan", "111"))
    > a.Add(New Customer("bill", "222"))
    >
    > Return a.ToArray(GetType(Customer))
    >
    > I am getting an error when I try to do this that says
    > You must implement a default accessor on system.array because it inherits from
    > ICollection.
    >
    > I feel like I am close but I still can't get it to work.


    Hold the press! I think a lightbulb went on!
    I guess I should return it as an array of Customer...

    As in
    <WebMethod()> Public Function GetArray() as Customer()
    Dim a As New ArrayList

    a.Add(New Customer("jan", "111"))
    a.Add(New Customer("bill", "222"))

    Return a.ToArray(GetType(Customer))
    Molalla Attenborough, Dec 30, 2003
    #6
  7. Molalla Attenborough

    Jan Tielens Guest

    So it works now?

    --
    Greetz,
    Jan
    __________________________________
    Read my weblog: http://weblogs.asp.net/jan
    "Molalla Attenborough" <> schreef in bericht
    news:ek%...
    > "Molalla Attenborough" <> wrote in message
    > news:...
    > > "Jan Tielens" <> wrote in message
    > > news:...
    > > > You can create a class to store date, for example suppose you want to
    > > > retrieve Customer information:
    > > > In your Webservice you can return an array of customer objects:
    > > > Dim a As New ArrayList
    > > >
    > > > a.Add(New Customer("jan", "111"))
    > > > a.Add(New Customer("bill", "222"))
    > > >
    > > > Return a.ToArray(GetType(Customer))
    > > >
    > > > --
    > > > Greetz,
    > > > Jan

    > >
    > > This is the part that I am stuck on.
    > > Do I return it as an array?
    > > As in:
    > >
    > > <WebMethod()> Public Function GetArray() as array
    > > Dim a As New ArrayList
    > >
    > > a.Add(New Customer("jan", "111"))
    > > a.Add(New Customer("bill", "222"))
    > >
    > > Return a.ToArray(GetType(Customer))
    > >
    > > I am getting an error when I try to do this that says
    > > You must implement a default accessor on system.array because it

    inherits from
    > > ICollection.
    > >
    > > I feel like I am close but I still can't get it to work.

    >
    > Hold the press! I think a lightbulb went on!
    > I guess I should return it as an array of Customer...
    >
    > As in
    > <WebMethod()> Public Function GetArray() as Customer()
    > Dim a As New ArrayList
    >
    > a.Add(New Customer("jan", "111"))
    > a.Add(New Customer("bill", "222"))
    >
    > Return a.ToArray(GetType(Customer))
    >
    >
    >
    Jan Tielens, Dec 30, 2003
    #7
  8. Do you have Macromedia Flash Remoting? Which version of
    Flash are you using? Flash MX 2004 Professional is
    supposed to allow Flash clients to consume web services
    from .Net (thought I haven't tried it), stherwise it is
    much easier to consume a .Net web service if you have the
    Flash Remoting software.

    I have a simple demo of a Flash MX client to a .Net web
    service. You can view it at:

    http://www.infoscico.com/FlashWebService/DbService.html

    I can send you the code if you would like to see it.
    It's passing data to the Flash Client in a DataSet, which
    is a useful way of passing complex data. It's not
    perfect. I couldn't find a way to pass a DataSet back to
    the web service.



    >-----Original Message-----
    >My task seems simple: I want to create a vb.net

    webservice and consume it
    >with a client created in Macromedia FlashMX.
    >
    >Let's get this out of the way - I don't want to use

    Coldfusion for data access.
    >I do not want to use vb.net to create my client

    interface. I want my service
    >to return a plain old array of complex types.
    >
    >FlashMX doesn't work well with XML data serialized by

    returning a dataset
    >object from a public function in the service.
    >
    >I have been trying to find a way to return the data from

    the service in a manner
    >that Flash can utilize. I have made some headway but I

    need a little more help.
    >
    >Can anyone show me a way to return data from a vb.net

    webservice in a format
    >that is serialzed as an array of complex types? I would

    really appreciate it.
    >
    >I don't need the code to fill datasets. I just need to

    know how to proceed from
    >there.
    >
    >Thanks in advance!
    >
    >
    >.
    >
    Patrick Wenzel, Dec 31, 2003
    #8
    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. KK
    Replies:
    2
    Views:
    552
    Big Brian
    Oct 14, 2003
  2. Steve Kuhn
    Replies:
    2
    Views:
    352
    majiofpersia
    Jul 29, 2003
  3. Milsnips

    need help returning webservice data in arraylist...

    Milsnips, Sep 2, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    155
    Elena Kharitidi
    Sep 23, 2004
  4. Patrick.O.Ige

    returning XML data from sqxml webservice

    Patrick.O.Ige, Dec 15, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    257
    Patrick.O.Ige
    Dec 15, 2006
  5. adh

    How to Webservice returning String() in VB.NET

    adh, Sep 24, 2007, in forum: ASP .Net Web Services
    Replies:
    10
    Views:
    854
    John Saunders [MVP]
    Sep 25, 2007
Loading...

Share This Page