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 example that follows.

<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. ...

Get Programming Flex 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.