hide side navigation
    5 most recent
    Web Services
    Library's
    Component's
    Applications
    Articles
  Flash button as Flex icon  Flex form by email  Hello Remoting with AS3  AS3 Saving data from Flash  AS3 Loading data into Flash  Fire Effect  Contact form  Dragable buttons  Hello World with openamf  Loading helper classes  Upload with Flash 8  Transitions effects  Snapshot with Flash 8  Hello World Remoting AS2  Flash AS2 Remoting Connector  Saving data from Flash  Loading data into Flash  FlashCom & Remoting login  Cell Renderer API  Editing a table using remoting components  Flash MX2004 web service classes  Browsing a catalog  amfphp Documentation  Hello World Remoting  Online Store with AMFPHP  Flash clients for Web Services  Web Service Walk Though with NuSoap  Popup windows in flash with javascript  Installing Apache/PHP  MoreOver News Feeds  Load Edit Save Text Files via CGI  Save Movie Clip Postion via PHP and MySQL
Current Page (1) Next Page >> 1 | 2 | 3 | 4 | 5

Using the Flash MX 2004 Web Service Classes


By: Jeffrey Hill

Update: 2/19/2004 - If you are having problems with Nusoap and the Crossdomain policy file when using HTTP 1.1 - please read the bottom of the following message http://www.flash-db.com/Board/index.php?board=9;action=display;threadid=6052

Flash MX 2004 comes with two client side methods for connnecting to web services. The first is by using the web service connector component, the second is by using the web service classes. This tutorial deals with the web service classes, which can be found in the mx.services package. These classes can only be used with ActionScript and are not visual like the connector component. We'll be covering the WebService, PendingCall, Log, and SOAPCall classes in this tutorial.

The main advantage of using the web services class over the web service connector component is that you have a bit more control over the interaction between flash and the service, and the debugging is also more in-depth. The downside is that it can be more time consuming and binding the results to other components is not as easy as with the connector component. We'll be covering the connector component in the next tutorial in this series.

Both of the two methods for connecting to web services in Flash MX04 have a couple of disadvantages. The main being that it can be really slow when returning larger datasets. The reason for this is that, even with the mx2004 speed improvments, it can take a lot of processor power to convert the returned xml into flash actionscript objects. There are a couple of ways to mask this slow performance, such as turning on doLazyDecoding, but overall when returning large result sets from a web service it is a far better solution to go with Flash Remoting. Flash remoting will return the result set as AMF instead of XML which has a much faster transfer speed (much more compressed) and does not need to be converted to flash actionscript (as it already is).

The second disadvantage of using the new built in client side web service features of flash mx 2004 are the security features. In order to use a web service that is not located on the same server, the owner of that service would need to place a cross domain policy file allowing the flash movie access to it's service. This in a way defeats the purpose of web services, as shown by the following quote.

A simple way for any programming language from any server, device, other application, etc - to communicate with any other server, device, application in any programming language. - Intro to webservices tutorial.

To illustrate this point - what would be the chance of Amazon or Google implementing a cross domain policy file so that www.someSite.com could use flash to access there web services... (<allow-access-from domain="*" />) One thing to note: This security feature is only required when the movie is published and placed on a server, locally or in the flash authoring environment there are no restrictions. Using Flash Remoting with web services will eliminate this issue.

Lets get started

This tutorial covers one sample actionscript file. To start we go over the basic code needed, then add more code for different features as we move on. The tutorial will not be going over what to do with the returned data in flash, only how to get it there. To get started:

And that's it for setup, the most important part is to drag an instance of the WebServicesClasses onto the stage (or into the documents library).

We are going to be testing with the Flash-db Company information service (that is also referenced in the ActionScript Dictionary). You can find out more details on this service here.

Another good way to find out information on any service is by using the Web Services Panel, which can be found at: Window > Development Panels > Web Services. To become familar with the web service that we will be using. Open up this panel and add in the following WSDL file: http://www.flash-db.com/services/ws/companyInfo.wsdl. It should look something like the following.

By using the web services panel you can visually view the methods associated with that service and all of it's expected inputs and outputs. In this case the result is an object of company information. On the next page we'll go over the code needed to invoke this service.

Current Page (1) Next Page >> 1 | 2 | 3 | 4 | 5