Accessibility

Table of Contents

Getting a Handle on Web Services in Macromedia Flash MX Professional 2004

Types of Web Services That Work with Flash MX Professional 2004

Macromedia Flash MX Professional 2004 has native support for SOAP and XML Remote Procedure Call (XML-RPC) web services. It doesn't matter which programming platform the web services are written in. One thing to pay attention to, however, is that Flash MX Professional 2004 doesn't natively support ASP.NET DataSets as of this release. You can work around this by parsing web service responses yourself, but you cannot bind directly to the .NET DataSet.

You can consume SOAP-based web services with the WebServiceConnector component or by using the ActionScript WebService API. You can consume XML-RPC web services through the RPC ActionScript API, a lower-level API on which the SOAP API is based.

An alternative to a SOAP-based web service is a Representational State Transfer (REST) web service. A REST-based web service is different from SOAP in that calls to it incorporate the method name directly into the URI and pass parameters through a query string. The web service will return an XML response. The WebService API in Flash does not support REST-based web services. However, you can still consume them in Flash if you use a server-side script to connect to the web service and the Flash-native XML class to parse the XML response.

Under the SOAP umbrella, which includes the majority of web services available at the moment, Flash supports RPC-style and document-style web services. Remote Procedure Call (RPC) style means that the SOAP message formats for both requests and responses include a wrapper element containing the operation or method name. In document style, request and response SOAP messages do not contain this wrapper element. The two styles are distinguished in the WSDL by the style attribute within the soap:binding and/or the soap:operation tag. Here is an excerpt from a WSDL document describing an RPC-style web service:

<binding name="sampleService">
   <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> 
  <operation name="sampleMethod">
   <soap:operation  style="rpc" soapAction="http://sample_service_action.com/" /> 
  <input>
   <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> 
   </input>
  <output>
   <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> 
   </output>
   </operation>
 </binding>

Here is an excerpt from a WSDL describing a document-style web service.

<binding name="sampleService">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
 <operation name="sampleMethod">
  <soap:operation style="document" soapAction="http://sample_service_action.com/" /> 
 <input>
  <soap:body use="literal" /> 
  </input>
 <output>
  <soap:body use="literal" /> 
  </output>
  </operation>
 </binding>

Notice the different values of the style attributes. Flash supports both styles.

As for the types of data that the web service can process or return, Flash supports any web services that accept and return strings, numbers, objects, arrays and other data types native to Flash. If the data returned is in a foreign language, Flash will render it correctly as long as the XML response is UTF-8 encoded. Lastly, Flash can even invoke web services that process binary data, such as a file comparison web service, as long as the return type is something that Flash can understand, such as a boolean.