5,447,640 members and growing! (20,421 online)
Email Password   helpLost your password?
Languages » C / C++ Language » General     Intermediate

Flash and WebSerives - Part 2

By daniel_nilsson

Here, you can read about a Serialized webservice which can return multiple rows.
C#.NET 1.1, Win2K, WinXP, Win2003, Windows, .NET, ASP.NET, Visual Studio, VS.NET2003, Dev

Posted: 13 Jan 2006
Updated: 13 Jan 2006
Views: 11,048
Bookmarked: 8 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
3 votes for this Article.
Popularity: 1.24 Rating: 2.60 out of 5
1 vote, 33.3%
1
0 votes, 0.0%
2
1 vote, 33.3%
3
0 votes, 0.0%
4
1 vote, 33.3%
5

Sample Image

Introduction

In this second-part article, I just add a new serialization class and a new method to the webservice described in part one.

Background

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.

Using the code

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()
    {
        
    }
}

History

Good luck... Check out the first article: Flash and WebSerives.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

daniel_nilsson


Systemdeveloper at DEN Production in Sweden
Occupation: Web Developer
Location: Sweden Sweden

Other popular C / C++ Language articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 2 of 2 (Total in Forum: 2) (Refresh)FirstPrevNext
Subject  Author Date 
Questionhelp me to bind webservice with flash!!! [modified]memberchiragfriend2005622:09 18 Sep '07  
QuestionGetting in contactmemberSailor670:15 23 May '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 13 Jan 2006
Editor: Smitha Vijayan
Copyright 2006 by daniel_nilsson
Everything else Copyright © CodeProject, 1999-2008
Web18 | Advertise on the Code Project