Flash MX 2004 Professional 20 Feb 2004 12:59 am
Flash, Web Services, and .NET DataSets
I’m often asked about connecting to .NET Web Services in Flash. Specifically, developers ask me whether Flash supports .NET DataSets. The short answer is no (not yet, anyway). However .NET developers do have options.
Flash engineer and general server-side technology guru, Mark Sheperd, sent me an example several months ago. I thought some of you might find it helpful.
Flash MX 2004 Professional cannot handle .NET datasets, either typed or untyped. Instead of returning a dataset, the suggested technique, in your C# or VB code, is to iterate over the DataSet, and build an array of objects, which is what you return from the webservice. Here is an example of a webservice that returns an array of objects…
<%@ WebService Language="C#" Class="Employees" %>
using System;
using System.Web.Services;
public class Employee
{
public String name;
public int department;
}
[WebService(Namespace=”http://services.r.us/”,Description=”Access the Employee database”)]
public class Employees
{
[WebMethod(Description=”Get a list of employees”)]
public Employee[] getEmployees()
{
Employee [] employees = new Employee[2];
employees[0] = new Employee();
employees[0].name = “Bob”;
employees[0].department = 123;
employees[1] = new Employee();
employees[1].name = “Mary”;
employees[1].department = 456;
return employees;
}
}
Here are a couple of public webservices, built in .NET, that return arrays of objects, rather than datasets.
http://ws2.serviceobjects.net/yp/YellowPages.asmx?WSDL
http://www.swanandmokashi.com/HomePage/WebServices/StockQuotes.asmx?WSDL

on 20 Feb 2004 at 3:38 am 1.PaulWeston said …
Thanks a lot for that tip
on 20 Feb 2004 at 8:14 am 2.roemer said …
Ã? have a webservice, returning array’s and objects.
How can i trace an array? or use the data in it? not with the UI object.
I already know how to catch one… the first.
please help
on 04 May 2004 at 1:54 pm 3.kanna said …
I’d really appreciate if someone could provide a solution to pass action script class to a .net service
on 02 Aug 2004 at 7:17 am 4.Dr. Shim said …
To pass an ActionScript type back to .NET, you would have to construct a SOAP packet in ActionScript containing your type.
on 18 Oct 2004 at 10:00 pm 5.David Dumas said …
FlashOrb from FlashOrb.com allows you to return a .net dataset to flash. It is going the other way that is the problem. Flash recordsets cannot be passed back as a .net dataset. This is a real problem, as asp.net does this natively - i.e asp.net databound controls can call DataAdator.Update(theDataSet), without any additional code. Macrromedia needs to step up to the plate and provide native .net object serialization form the Flash client. Then they can say “we support .net”
on 06 Dec 2004 at 7:47 am 6.bob said …
There is something different about an array returned from .Net via SOAP and one created in ActionScript. The method prescribed here does return an array, but if you use that array as a dataprovider for a datagrid, the grid acts odd. If you delete use removeitat, or sort the grid, large portions of the data ‘blanks out’. The data is still there when you click to edit the grid, but appears blank when you scroll up and down.
on 12 Jan 2005 at 12:18 pm 7.hugo said …
I tried getting the webservice above to work by binding to a datagrid dataprovider. I couldn’t get it to work. Anyone have success with it?
This is the one I was using:
http://www.swanandmokashi.com/HomePage/WebServices/StockQuotes.asmx?WSDL
I also used textInput to bind the string parameter for the webservice and I entered MSFT since I know this returns results. But, still doesn’t work. Datagrid is just empty.
on 15 Apr 2005 at 2:38 pm 8.marc said …
I am puzzled and need your help… (background: I’ve been working on implementating a software system in .NET for the past six months. My manager has decided to dump the existing ASP.NET WebUI, to be replaced by a Flash UI).
I am trying to find some examples of “good” ways of exchanging data between my .NET server(s) and the Flash UI application. I see the above recommendation that returning datasets as arrays of objects is the best approach for “mass” data, yet other places I see that this doesn’t work. I’m also concerned about security of the WebServices being used by the Flash UI, and establishing, authenticating, and maintaining an identity in the Flash UI that is used in interacting with the .NET server(s) to provide authentication and authorization for the data being accessed.
on 31 May 2005 at 10:08 pm 9.Mark said …
Thanks a billion!
I was a bout to start burning some books when I saw this. Now I get to figure out how to turn my DataSet into a object… yay!
on 07 Jun 2005 at 7:56 pm 10.superabe said …
Is this post still accurate?
As per this url
http://livedocs.macromedia.com/flashremoting/mx2004/using_flash_remoting/wwhelp/wwhimpl/js/html/wwhelp.htm
It seems you can return datasets to flash ?
on 04 Aug 2005 at 6:09 pm 11.Erhazmo said …
Im trying to write a Flash DataProvider that can receive/send in the Microsoft DiffGram Format for sending/consuming .NET datasets
on 31 Aug 2005 at 6:00 pm 12.Tj said …
Hi,
I am using the WebServicesConnector in Flash MX 2004 for the first time. I got the tutorial working that requests tips, returned as text.
I am trying to get a datagrid to display and array of data but am having trouble getting it to work. Do you have to do anything more than the steps in the tutorial (for datagrids)? Tj
on 15 Oct 2005 at 5:11 pm 13.iliad2b said …
take a look at amfphp in the how2…. it might help
on 30 Nov 2005 at 7:38 am 14.Jason said …
Sorry - complete newbie. My colleague and I are working on doing this sort of thing right now.
How do I then use the array that is returned from the webservice?
There is quite a bit of data returned that I don’t need to display. So how can I sort throug it and select only the data I want to bind to my display components?
on 03 Jan 2006 at 2:25 pm 15.Perica said …
How to return Microsoft Dataset from .NET web service to Flex.
Following discussion on this site I found more works on this link: http://weblogs.asp.net/astopford/articles/106476.aspx
This works but solution is not so elegant. Searching for better solution I found this link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service02112003.asp (pretty elegant).
1. Define a Item type (record)
private class Items
{
public int ItemNumber;
public string Description;
public Decimal Price;
}
2. Crate a web service which return a array of Items
[WebMethod()]
[return: XmlElement(typeof(Items[]))]
public XmlDataDocument GetTypedXmlDataDocument()
{
sqlDataAdapter1.Fill(typedDataSet1);
XmlDataDocument dataDoc
= new XmlDataDocument(typedDataSet1);
return dataDoc;
}
on 19 Jun 2006 at 12:55 pm 16.Reza said …
I think that Macromedia and Abode needs to be bought out buy some company who knows how to develop developer tools, they just suck at it.
Or they need to hire some body like Anders Hielsberg. Even the basic stuff such as editor in Flash sucks. I can not believe that there is no company out there who can challange them. Not to mention their debugger, oh my oh my, people should be hanged for writing that thing. They may be need to drop their crappy ide and use eclipse as a platform, here is an idea!
on 04 Jul 2006 at 3:48 pm 17.Perica said …
[WebMethod]
public Northwind.CategoriesDataTable CategoriesDataSet()
{
Northwind.CategoriesDataTable tbl = new Northwind.CategoriesDataTable();
NorthwindTableAdapters.CategoriesTableAdapter ad = new NorthwindTableAdapters.CategoriesTableAdapter();
ad.Fill(tbl);
return tbl;
}
…
on 04 Jul 2006 at 3:49 pm 18.Perica said …
on 24 Aug 2006 at 1:14 pm 19.Jason Merrill said …
I thought I had this figured out, but Arrays are coming across weird in a .NET webservice as generic objects not arrays that Flash can understand. I never noticed it before because I can still reference the properties in objects in the array OK, just not the array itself. For example (projObj is the object of arrays and objects resulting from my webservice method call):
trace(projObj.Content.Topics) //traces as undefined. Expected an array trace(typeof(projObj.Content.Topics)); //traces as object !?!
and
trace(projObj.Content.Topics[0]) //traces [object Object],undefined //but I expected [object Object], [object Object], [object Object]
Finally:
projObj.Content.Topics[0].TextAreas[0].HtmlText //traces the value I am expecting!!! ???
What’s up? I can get the property values OK, but I cannot treat the array as an array as you would in Flash?
on 18 Sep 2007 at 1:59 am 20.chirag Rajput said …
hey, can anyone tell me the step , how i can bind this arry object with the flash componet or dataset.
i try it ,but it give me error dataset is empty.
please,do some needfull.
because,it’s urgent for me.
thanks in advance!