Click here to Skip to main content
12,759,231 members (32,701 online)
Click here to Skip to main content
Add your own
alternative version

Stats

20.4K views
102 downloads
12 bookmarked
Posted 13 Jan 2006

Flash and WebSerives - Part 2

, 13 Jan 2006
Rate this:
Please Sign up or sign in to vote.
Here, you can read about a Serialized webservice which can return multiple rows.

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

Share

About the Author

daniel_nilsson
Architect Värderingsdata
Sweden Sweden
Systemdeveloper at Värderingsdata in Sweden

You may also be interested in...

Comments and Discussions

 
Questionhelp me to bind webservice with flash!!! [modified] Pin
chiragfriend20056218-Sep-07 2:09
memberchiragfriend20056218-Sep-07 2:09 
QuestionGetting in contact Pin
Sailor6723-May-07 0:15
memberSailor6723-May-07 0:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170217.1 | Last Updated 13 Jan 2006
Article Copyright 2006 by daniel_nilsson
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid