1 / 27

Flex Data Communications

Flex Data Communications. Nick Kwiatkowski, Michigan State University. Data Communications. Why communicate? Your Flex applications most likely want to have fresh data from a database or other webservice You may need to send current data to your end-users Three-Tiered applications

Download Presentation

Flex Data Communications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Flex Data Communications Nick Kwiatkowski, Michigan State University

  2. Data Communications • Why communicate? • Your Flex applications most likely want to have fresh data from a database or other webservice • You may need to send current data to your end-users • Three-Tiered applications • Data -> View -> Controller • Your data tier doesn't have to be local!

  3. Data Communication Basics • Flex currently supports three types of data communications with external sources : • XML via HTTP Requests • SOAP Web-Services • AMF / Remote Objects • With this combination, you can virtually talk to any back-end server

  4. HTTPService • The HTTPService MXML tag allows for the most basic communication level between you and a web server • Mostly used for legacy middleware applications and static XML documents • Any application that can generate proper XML on the fly can talk to your Flex app using this tag

  5. HTTPService • How it is used: • Place the HTTPService tag at the application or component level (root level) of your current MXML document.

  6. HTTPService • Common Parameters: • id – Used to name the component • url – The full URL to the component • result – The event function that will be fired when the result came back successfully • The XML document will be stored in the event.result object • fault – The event function that will be fired when the result did not come back correctly.

  7. Web-Services • SOAP or Web-Services can easily be called using the <mx:WebService> component. • Web Services allow you to communicate data back to the web-server, and retrieve typed objects (strings, numbers, arrays, queries) • Because it is based on XML, it is very verbose, and often slow for large sets of data.

  8. Web-Services • How it is used: • Place the <mx:WebService> tag at the root level of the document (application or component) that you are working on.

  9. Web-Services • Common Parameters: • id – Used to name the object • wsdl – Points to the WSDL (Web Service Descriptor) file. This file is different for each language • showBusyCursor – Changes the current pointer to a rotating clock to let the user know something is happening

  10. Web-Services • Passing parameters: • You can pass parameters to web-services by naming operations (methods or functions). • The operation tag allows for result or fault functions

  11. Web-Services • Passing Parameters: • You CAN use binding statements within your parameters (to bind to user’s input, for example) • Webservices are Case Sensitive, so make sure that your parameters match case • Some application servers, such as ColdFusion don’t care about case-sensitivity • Watch out with ColdFusion, because it transforms all cases to Uppercase when transmitting data!

  12. AMF • AMF, or Remote Objects are the most efficient way to transmit data between your application server and your Flex Application • Data is transmitted in Binary, so it is fairly compressed • Objects will stay in their native form when transmitted • Very easy to use**

  13. AMF • So, why NOT use AMF? • Only ColdFusion, ActionScript and Java are supported by Adobe. • PHP has an open source solution, however. • Fairly hard to setup your environment • Requires files to be copied down from your development / deployment environment • Makes a lot of assumptions that can hurt you your first time through.

  14. AMF • What your need: • You need to get a copy of services-config.xml from your environment. • ColdFusion this is your <webroot>/WEB-INF/flex/ • JRun this is <webroot>/<ear file>/WEB-INF/flex/ • If you do not develop your applications locally, you need to modify this file. • Copy the ColdFusion destination section and my-cfamf sections to meet your needs.

  15. AMF • Services-Config? • This file is compiled into your project and will convert the “destination” portion of your RemoteObject call to the tcp/ip hostname and port numbers • Depending on how this file looks, your application can be very portable, or not portable at all.

  16. AMF • How it is used: • Just the same as WebService, but instead of the WSDL parameter, you use the destination and source parameters • Destination = Destination from the services-config.xml file • Source = If using ColdFusion, this the path to the CFC, in dot notation

  17. Advanced Communication • By customizing the services-config.xml file, you can also enable some advanced communication • By using the <mx:Producer> and <mx:Consumer> tags, you can “produce” content to other applications or Coldfusion Event Gateways. • This allows for Many-to-One or Many-To-Many applications with little or no work.

  18. ColdFusion Demo What is it, and how is it used with Flex.

  19. ASP.NET Demo What is it, and how is it used with Flex?

  20. PHP Demo What is it, and how is it used with Flex?

  21. ColdFusion and Flex • When using ColdFusion with Flex Builder, there are certain wizards available to the developer which helps make data communications quicker. • These need to be installed manually with Flex Builder; follow the directions in the readme. • You also need to configure the Data Sources within ColdFusion before you can begin.

  22. ColdFusion and Flex • Within the Preferences dialog box, go to the RDS configuration to setup your connection with ColdFusion • Context Root and User Name are un-used unless you are using the Multi-Server version of ColdFusion

  23. ColdFusion and Flex • Open the “RDS Dataview” tab by going to Window -> Show View -> Other -> Coldfusion -> RDS Dataview • You will then be shown all the Data Sources available to Coldfusion. You can browse the data, too! • Double-Click to launch thequery browser.

  24. ColdFusion and Flex • Right click on a table to template out CFCs for your Flex apps • Demo!

  25. Where to find more info • AMF-PHP Project • http://www.amfphp.org • Adobe DevNet • http://www.adobe.com/devnet/flex/ • Adobe LiveDocs • http://livedocs.adobe.com/flex/2/ • Community Flex Project • http://www.cflex.net

  26. Where to find more info • Adobe Flex 2: Training from the source • Jeff Tapper, et al

  27. Questions?

More Related