![]() |
Languages »
C / C++ Language »
General
Intermediate
Flash and WebSerives - Part 2By daniel_nilssonHere, you can read about a Serialized webservice which can return multiple rows. |
C#.NET 1.1, Win2K, WinXP, Win2003, ASP.NET, VS.NET2003, Dev
|
|
Advanced Search |
|
|
|
||||||||||||||||

In this second-part article, I just add a new serialization class and a new method to the webservice described in part one.
Before, we just got a single row information from the webservice, in this case, we can get multiple rows. The technique is I'm using an array here to return results.
At the top of the class file, we add our array for simulating the database :)
string[] aUsers = new string[]{"admin","nisse","kalle","Jonas"};
Here is the new serialization class:
[Serializable()]
public class oUserList
{
public string sName;
public oUserList()
{
}
public oUserList(string sTheName)
{
sName = sTheName;
}
}
And this is the method:
[WebMethod]
public oUserList[] getList()
{
oUserList[] objUserList = new oUserList[aUsers.Length];
for(int i=0;i<aUsers.Length;i++)
{
objUserList[i] = new oUserList();
objUserList[i].sName = aUsers[i];
}
return objUserList;
}
We also add a new button and a list box in the Flash file. Here is the code for the Click event of the new button:
on(press)
{
var objGetUsers = _global.webServicen.getList();
objGetUsers.onResult = function(sResult)
{
var oUserList = new objGetUsers.oUsers();
oUserList = sResult;
myList = new Array();
_root.lbUserlist.dataProvider = myList;
for(i=0;i<oUserList.length;i++)
{
myList.addItem({label: oUserList.getItemAt(i).sName,
data: oUserList.getItemAt(i).sName });
}
}
objGetUsers.onFault = function()
{
}
}
Good luck... Check out the first article: Flash and WebSerives.
| You must Sign In to use this message board. | |||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 13 Jan 2006 Editor: Smitha Vijayan |
Copyright 2006 by daniel_nilsson Everything else Copyright © CodeProject, 1999-2009 Web11 | Advertise on the Code Project |