Using Web Services


Web services are a popular standard for client-server data communication. However, Flash Player has no built-in classes specifically designed for working with Web services. If you are using the Flex framework, you can employ the mx.rpc.soap.WebService class. In this book, we're concerned primarily with solutions that rely exclusively on the Flash Player API. For a description of the WebService class, see the Flex documentation.

If you are interested in a Web services solution that does not rely on the Flex framework, you have two options:

  • Write your own Web services framework in ActionScript. Although Web services appear in many forms, one of the most popular uses SOAP, an XML-based protocol that is sent over HTTP. Writing a Web service framework requires sending and loading XML data using URLLoader along with a custom SOAP parser.

  • Make standard requests to a server-side script that makes the Web service calls. The server-side script can return URL-encoded data or XML data.

Note

Another option is to manually create and parse SOAP requests and responses. This is advisable for only very simple cases. You can see an example of this in Chapter 15.


The second option is often the best. One obvious reason that server-side Web service proxies are a good idea is that server-side languages generally have robust Web service capabilities that can work with a variety of protocolsnot just SOAP. Server-side scripts can also generally parse Web service responses more quickly. They can relay the responses back to the client in a format that is more compact than SOAP (to limit the bandwidth overhead), and the server can even cache responses when applicable to limit the number of Web service requests.




Advanced ActionScript 3 with Design Patterns
Advanced ActionScript 3 with Design Patterns
ISBN: 0321426568
EAN: 2147483647
Year: 2004
Pages: 132

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net