O'Reilly logo

Programming Flex 2 by Joey Lott, Chafic Kazoun

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Web Services

Flash Player has no built-in support for SOAP web services. However, Flex provides a WebService component that uses built-in HTTP request/response support as well as XML support to enable you to work with SOAP-based web services. There are two ways you can work with the WebService components: using MXML and using ActionScript.

Using WebService Components with MXML

You can create a WebService component instance using MXML. When you do, you should specify an id and a value for the wsdl property, as in the following example:

<mx:WebService id="statesService" wsdl="http://www.rightactionscript.com/states/webservice/StatesService.php?wsdl" />

Web services define one or more methods or operations. You must define the WebService instance so that it knows about the operations using nested operation tags. The operation tag requires that you specify the name at a minimum. The following example defines an operation called getCountries. This means that the WSDL document must also define a getCountries operation.

<mx:WebService id="statesService" wsdl="http://www.rightactionscript.com/states/webservice/StatesService.php?wsdl">
  <mx:operation name="getCountries" />
</mx:WebService>

Once you've defined the WebService instance and an operation, you need to be able to call the method and handle the response, which we'll look at in the next few sections.

Calling web service methods

All operations that you define for a WebService component instance are accessible as properties of the instance. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required