Welcome, Guest
  • Author Topic: Webservice - dataset  (Read 2186 times)

    Swordfish

    • Jr. Programmer
    • **
    • Posts: 55
      • View Profile
      • Email
    Webservice - dataset
    « on: 03/22/06, 07:42 »
    Hi!

    I'm working on a webservice.
    What is the best way to recive a dataset, and pass it to a datagrid in FLash?

    Iv'e tried:

    var: "myService stuff here..."
    var myPCall:PendingCall = myWS.getImageTitles();

    myPCall.onResult = function(resultCall:Object){
         myGrid.dataProvider = resultCall;
    -----------------------  etc --------------------

    wont work.. ???

    /S-fish



    « Last Edit: 03/22/06, 08:07 by Swordfish »

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Webservice - dataset
    « Reply #1 on: 03/22/06, 08:11 »
    Since Webservices provides different XML structures, binding directly as dataprovider is not a good idea. Add the webservice in the Webservice Panel, inspect it, bind to the datagrid. An example to follow (Babelfish services) in http://www.macromedia.com/support/documentation/en/flash/documentation.html, Data Tutorials (scroll at the end of the page)

    Jorge

    Swordfish

    • Jr. Programmer
    • **
    • Posts: 55
      • View Profile
      • Email
    Re: Webservice - dataset
    « Reply #2 on: 03/22/06, 10:28 »
    Thanks Jorge..

    I think I'll use "the XML way"..This will pick out the first image title, from the dataset/service.

    titleData = myXML.firstChild.childNodes;
    imgTitle = titleData[1].firstChild.firstChild.firstChild.childNodes;

    Now, ...how do I loop through and pick out the other image titles?

    Thanks for some advice.
    /S-fish

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Webservice - dataset
    « Reply #3 on: 03/22/06, 10:53 »
    ???
    Looping trough the childNodes, using the properties or text nodes, this hangs on your XML. Use the standard XML methods, an example: http://www.flash-db.com/Board/index.php?topic=14807.0

    Jorge

    Swordfish

    • Jr. Programmer
    • **
    • Posts: 55
      • View Profile
      • Email
    Re: Webservice - dataset
    « Reply #4 on: 03/22/06, 21:11 »
    Hmm..I think this must be simple but..

    On method call for id1:

    xmlData = myXML.firstChild.childNodes;

    trace(xmlData) ...gives:

    <Image><id>1</id><title>Title1</title><info>Summer 2005....</info><path>images/img001.jpg</path></Image>

    I want to store id, title, info and path in separate variables like,

    videoId = myXML.firstChild.firstChild.firstChild.childNodes; ?
    videoTitle = ?
    etc....

    What is the best way to pick out these?
    Thankful for some advice.

    /S-fish
    « Last Edit: 03/22/06, 21:21 by Swordfish »

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Webservice - dataset
    « Reply #5 on: 03/23/06, 03:29 »
    Try this:

    myXML = new XML("<Image><id>1</id><title>Title1</title><info>Summer 2005....</info><path>images/img001.jpg</path></Image>")
    root = myXML.firstChild.childNodes
    for(var i=0; i<root.length; i++) trace(root.firstChild.toString())

    Now add a outer root node so CHildNodes point to Image, if not will be very difficult to parse

    Jorge

    Swordfish

    • Jr. Programmer
    • **
    • Posts: 55
      • View Profile
      • Email
    Re: Webservice - dataset
    « Reply #6 on: 03/23/06, 13:14 »
    Thank you..it works just fine!  :)
    « Last Edit: 03/23/06, 13:21 by Swordfish »