Développement web indépendant à Montpellier

Publié le jeudi 16 avril 2009 12:54:50

Créer un webservice en Actionscript 3 (AS3)

Il était possible avec Actionscript 2 (AS2) de créer directement des webservices. Cela a été retiré pour une obscure raison en actionscript 3, même si nous allons voir qu'il est toujours possible de les utiliser moyennant l'import d'une plugin.

Quoi qu'il en soit, voici un exemple de webservice en Actionscript 3.

Webservice kezako ?

Si vous n'êtes pas sensible à la programmation orientée objet, cela ne vous dira probablement rien. Cela permet l'échange de données entre applications à distance entre plusieurs applications différentes. Cela permet de communiquer via le web, entre applications de différentes plates-formes. Ainsi, on peut faire communiquer C# (CSharp) avec Java, et même Actionscript.

D'un point de vue plus "développement", cela permet d'instancier des objets à distance, à partir d'une application qui n'est pas forcément codée dans le langage que l'on utilise. (Instanciation d'objets d'une application C# à partir d'une application Flash/Actionscript, par exemple).

Webservice de météo

Notre exemple ira chercher la météo sur un Webservice fourni gratuitement par Globalweather, (je déconseille toute utilisation professionnelle de celui-ci, c'est régulièrement faux). Nous allons proposer de retrouver la météo dans les principales villes de France. Pour réaliser un Webservice en AS3, nous allons avoir besoin d'utiliser un composant additionnel, téléchargeable gratuitement : Webservice AS3 ce projet est disponible sur GoogleCode (subversion) et est sous licence .

Voici le résultat de notre WebService météo :

La source est en téléchargement gratuit à la fin de ce document. Notez que le serveur interrogé est fréquememnt en carafe, affichez le WebService dans une page web pour voir s'il est disponible : GlobalWeather. (Tellement souvent aux abonnés absents que j'ai modifié la source pour prévenir...enfin l'idée est là)

GlobalWeather : WebService météo, exemple en Actionscript

Source du WebService Météo

Tout d'abord il faut importer les bibliothèques puisque, je le rappelle, les webservices ne sont plus disponibles nativement en Actionscript 3 :

import be.wellconsidered.services.*;
import be.wellconsidered.services.events.*;

Au clic du bouton, on instancie l'objet WebService Actionscript, et on y attache les événements :

var oWebService:WebService = new WebService("http://www.webservicex.net/globalweather.asmx?wsdl");
var oOp:Operation = new Operation(oWebService);

oOp.addEventListener(OperationEvent.COMPLETE, this.SendResult);
oOp.addEventListener(OperationEvent.FAILED, this.SendFailed);

oOp.GetWeather(szVille, "France");

Il ne reste plus qu'à traiter les infos comme on le souhaite, ici le webservice renvoi une chaîne , nous la traitons donc comme telle (Voir un exemple de traitement de document XML en Actionscript).

public function SendResult(evt:OperationEvent):void
{
    var szResult:String = String(evt.data);
    this.monTextArea.text = szResult;
    var xml:XML = new XML(szResult);
    this.maLocalisation.text = xml.CurrentWeather.Location.toString();
}

Téléchargement de la Source FLA

Cette archive contient :

  • La source Flash .FLA,
  • La classe Actionscript liée avec le Webservice,
  • La bibliothèque Webservice AS3 wellconsidered (redistribuable sous licence GNU/GPL)
  • Le Flash compilé (SWF)

Articles connexes

Notez cet article !

  • Actuellement 5 sur 5 étoiles
  • 1
  • 2
  • 3
  • 4
  • 5

Note : 5/5 (3 notes attribuées)

Merci d'avoir participé !

Vous avez déjà noté cette page, vous ne pouvez la noter qu'une fois !

Votre note a été changée, merci de votre participation !

Bonne résolution ! j'arrête d'alourdir mes pages avec des boutons de partage, mais vous pouvez continuer de partager :-)

Commentaires

  1. Computer majors and graduate students are generally reluctant to learn a more

  2. Your work is very good and I appreciate you and hopping for some more informative posts. Thank you for sharing great information to us.
    http://...-examples/

  3. Interesting and amazing how your post is! It Is Useful and helpful for me That I like it very much, and I am looking forward to Hearing from your next.
    http://...y-fitness/

  4. I really impressed after read this because of some quality work and informative thoughts . I just wanna say thanks for the writer and wish you all the best for coming!

  5. Thanks for your information, it was really very helpfull.
    http://...awpros.com

  6. Hi, I have scanned the greater part of your posts. This post is presumably where I got the most valuable data for my exploration. A debt of gratitude is in order for posting, possibly we can see more on this. Are you mindful of some other sites on this subject.
    http://...ness-easy/

  7. That is the excellent mindset, nonetheless is just not help to make every sence whatsoever preaching about that mather. Virtually any method many thanks in addition to i had endeavor to promote your own article in to delicius nevertheless it is apparently a dilemma using your information sites can you please recheck the idea. thanks once more.
    http://...-business/

  8. Positive site. where did u come up with the information on this posting?I have read a few of the articles on your website now. and I really like your style. Thanks a million and please keep up the effective workhttp://...launch.com

  9. http://ww... | http://www.poker18dewa.com |

    Very interesting points you have observed , thanks for posting .

  10. Really a nice blog. Keep growing.
    for recent tech updates visit http://...onwebs.com

  11. Webroot.com/safe- Experience next-generation Security level with Webroot on your all devices. Install and activate webroot from www.webroot.com/safe and don’t forget to run webroot safe scan to feel secure anywhere.webroot.com/safe is a computer security software program for Microsoft Windows users that combine software as a service cloud protection with traditional Antivirus and anti-spyware desktop technologies. Built into the suite is a two-way firewall, a registry cleaner, Email anti-spam, secure browsing, anti-phishing and a password management service. The suite was initially released on July 26, 2010, as the 2011 version of the product.

    http://...t.com/safe

  12. Auto Glas... | Auto Glass Replacement |

    After study a few of the websites for your internet site now, and I genuinely as if your technique for blogging. I bookmarked it to my bookmark internet site list and will be checking back soon. Pls look at my website likewise and let me know what you think.

  13. Votre blog est très intéressant, fascinant et d'autant plus utile. Il n'y a rien de bon à trouver des informations de qualité, et vraiment je peux dire que c'est l'un des meilleurs. Veuillez continuer à partager. Merci!

  14. Have a natural attraction for women cosmetics and <a http://...gt;replica watches uk</a> clothes, no more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment <a href="http://...gt;replica watches uk</a>. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the <a href="http://...;>cheap replica watches</a>.

  15. Why Customers choose COSJJ.com to buy Cosplay Costumes

    Cosjj.com have been making Cosplay Costumes for about 10 years. The COSJJ Workers are those who also love cosplay at the weekend. So when you go to here, please shop with fun.

    Always shop with confidence under COSJJ.COM since the shop is known to be the best supplier in terms of pre-made costumes as well as custom-made costumes. No more worries regarding personal and confidential information since all will be secured and will be catered y the best security checkout, the Nexcess, Paypal, and Starfield SSL Certificate. Expect that sensitive information like contact information and credit card data will be gathered and used in the most secured way possible.

    http://...y-costumes
    http://...y-costumes
    http://...y-costumes

  16. Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work.

  17. www.webroot.com/safe -24/7 technical support for Webroot antivirus, call us to get instant support on webroot installation issues Dial toll free 1-844-833-0610.
    https:/....org/safe/

  18. Where to seek out webroot Key Code? The Webroot security package is simple to setup &amp; install at webroot.com/safe. Simply find 20-character alpha-numeric code that is...
    http://...-safe.org/

  19. Web-root -24/7 technical support for Webroot antivirus, call us to get instant support on webroot installation issues Dial toll free 1-844-833-0610.
    https:/...-root.org/

  20. Experience next generation Security level with Webroot in your all devices. Install and activate webroot from www.webroot.com/safe and don’t forget to run webroot safe scan to feel secure anywhere.
    https:/...-com-safe/

  21. www.webro... | www.webroot.com/safe | webroot/safe - download (windows 10) |

    Webroot Support experts can lend their hand to download, install and update Webroot Spy Sweeper Antivirus on your system. We can also repair all errors that may crop up while installing and configuring Webroot Antivirus on your PC. We can help you detect and remove malicious threats, malware and spyware by performing a quick scan on all files and folders. With our robust technology, we can destroy suspicious programs and infected files from your system. Our antivirus experts can clean all online threats, including Trojan, root kits, key loggers, and worms in just single sweep. We can optimize your computer’s speed and efficiency and also protect it from being sluggish.
    http://....org/safe/

  22. www.webro... | www.webroot.com/safe | Activate webroot at webroot safe |

    Where to seek out webroot Key Code? The Webroot security package is simple to setup &amp; install at webroot.com/safe. Simply find 20-character alpha-numeric code that is..
    http://...-safe.org/

  23. Webroot Support provides all-round assistance for Webroot Antivirus. As soon as you register yourself for the use of Internet facility and get the advantage of surfing the World Wide Web, you are open to innumerable threats transmitted to your system due to online browsing sessions. Encounter perfect malware blocking with Webroot Antivirus. Let Webroot Support with its techsmarties help you protect your system and rectify the security issues. We at Webroot Support , have team of experts who help you or guide through all the stages of Webroot installation process.
    http://...b-root.org

  24. webroot.c... | webroot.com/safe to get webroot safe setup |

    Experience next generation Security level with Webroot in your all devices. Install and activate webroot from www.webroot.com/safe and don’t forget to run webroot safe scan to feel secure anywhere.
    http://...-com-safe/

  25. www.webro... | www.webroot.com/safe | webroot/safe - download (windows 10) |

    Webroot Support provides all-round assistance for Webroot Antivirus. As soon as you register yourself for the use of Internet facility and get the advantage of surfing the World Wide Web, you are open to innumerable threats transmitted to your system due to online browsing sessions. Encounter perfect malware blocking with Webroot Antivirus. Let Webroot Support with its techsmarties help you protect your system and rectify the security issues. We at Webroot Support , have team of experts who help you or guide through all the stages of Webroot installation process.
    http://....org/safe/

  26. www.webro... | www.webroot.com/safe | Activate webroot at webroot safe |

    Where to seek out webroot Key Code? The Webroot security package is simple to setup &amp; install at webroot.com/safe. Simply find 20-character alpha-numeric code that is...
    http://...-safe.org/

  27. Webroot Support experts can lend their hand to download, install and update Webroot Spy Sweeper Antivirus on your system. We can also repair all errors that may crop up while installing and configuring Webroot Antivirus on your PC. We can help you detect and remove malicious threats, malware and spyware by performing a quick scan on all files and folders. With our robust technology, we can destroy suspicious programs and infected files from your system. Our antivirus experts can clean all online threats, including Trojan, root kits, key loggers, and worms in just single sweep. We can optimize your computer’s speed and efficiency and also protect it from being sluggish.
    http://...b-root.org

  28. webroot.c... | webroot.com/safe to get webroot safe setup |

    Experience next generation Security level with Webroot in your all devices. Install and activate webroot from www.webroot.com/safe and don’t forget to run webroot safe scan to feel secure anywhere.
    http://...-com-safe/

  29. Visit www.norton.com/setup for setup, download, reinstall, enter and activate your norton product key to setup your account.Step-by-Step guide for Norton setup key, Download &amp; installation from norton.com/setup website.

  30. welcome to avg.com/retail website With the development of the digital world, online protection is crucial. It is extremely important to protect your PCs, Mac, computers as well as mobile devices and tablets with avg.com/retail. This can be done with the help of effective internet security and anti-virus products from avg.com/retail that safeguards all devices used on digital platforms.

  31. I am very happy to discover your post as it will become on top in my collection of favorite blogs to visit.

  32. Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon!

  33. Ergonomis... | Ergonomische Eingabegeräte |

    I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well..

  34. voyance p... | voyance par telephone gratuit |

    This is such a great resource that you are providing and you give it away for free.

  35. Wonderful article, thanks for putting this together! This is obviously one great post. Thanks for the valuable information and insights you have so provided here.

  36. Your website is really cool and this is a great inspiring article. Thank you so much.

  37. belize re... | belize real estate for sale |

    No doubt this is an excellent post I got a lot of knowledge after reading good luck. Theme of blog is excellent there is almost everything to read, Brilliant post.

  38. Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts.

  39. website d... | website designer san diego |

    The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.

  40. I have read your article, it is very informative and helpful for me.I admire the valuable information you offer in your articles. Thanks for posting it..

  41. SUP Multi... | SUP Multiplayer Racing Hack Tool & Cheats |

    SUP Multiplayer Racing Hack will let you to buy all items for free. Below you will see all the cheats needed to hack SUP Multiplayer Racing These Cheats for SUP Multiplayer Racing work on all iOS and Android devices. You will also not need a jailbreak or rooted phone.

    https:/...ol-cheats/

  42. moins laisser vos remarques et critiques -acerbes- sur l'article, les points de vue pertinents sont

  43. Steady and instinctive, this blogger hands it in unfailingly.

  44. Message très utile. C'est la première fois que je visite ici. J'ai trouvé tellement de choses intéressantes dans votre blog, en particulier sa discussion. Vraiment son excellent article. Continuez!

  45. sf@gmail.com | Saint Augustine Car Title Loans |

    Shrewdly worked by the creator and Stunningly delightful usage of words.

  46. http://ww... | http://www.agenslutena.com/penyebab-retina-lepas-ablasio-retina-obat-ampuh-tanpa-operasi/ |
  47. I really like reading through a post that can make people think. Also, many thanks for permitting me to comment!

  48. Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here

  49. Game Killer apk is an android application which helps you hack your favorite android games or applications without any issues.

  50. We aim to share High Quality Images of Hindu Gods for both desktop & mobiles.

  51. A debt of gratitude is in order for sharing the information, keep doing awesome... I truly delighted in investigating your site. great asset...

  52. much thanks to you for an incredible post.


  53. I definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.

  54. Super article. Thanks to you, I would sleep less stupid tonight!

  55. It’s appropriate time to make some plans for the future and it is time to be happy. I have read this post and if I could I wish to suggest you few interesting things or advice. Perhaps you could write next articles referring to this article. I desire to read even more things about it!

  56. If it's not too much trouble share more like that.

  57. I concede, I have not been on this website page in quite a while... in any case it was another delight to see It is such an essential point and overlooked by such a variety of, even experts. experts. I thank you to help making individuals more mindful of conceivable issues.

  58. how to do... | how to download minecraft for free |

    This is extremely instructive substance and composed well for a change. It's pleasant to see that a few individuals still see how to compose a quality post!

  59. I think this is an okay article. You make this data intriguing and locks in. You give perusers a considerable measure to consider and I value that sort of composing.

  60. high top quality flash games on the

  61. Ryan Cata... | Ryan Cataldo NJ Criminal |

    It’s amazing in support of me to truly have a blog site, which will be valuable meant for my knowledge. Thanks admin.

  62. Superb article. Exceptionally intriguing to peruse. I truly love to peruse such a pleasant article. Much obliged! continue shaking.

  63. imo's free text, voice and video chat make it easy to stay in touch with your family and friends, wherever they are

  64. imo's free text, voice and video chat make it easy to stay in touch with your family and friends, wherever they are

  65. How To Ki... | How To Kiss A Man Review |

    it was a magnificent opportunity to visit this sort of site and I am upbeat to know. much thanks to you such a great amount for allowing us to have this open door..

  66. This Chromecast app, can be conveniently used provided it should be connected to a television set.

  67. Much obliged, that was a truly cool read!