Run the web services sample by opening the following URL in your browser: http://localhost:8400/samples/testdrive-webservice/index.html.
Note: Since this application accesses a live web service, you must have an Internet connection to run it.
Open main.mxml in the testdrive-webservice/src directory to examine the source code of the application.
You can also view the WSDL file for the web service used in this example at http://livecycledata.org/services/ProductWS?wsdl.
Using the WebService tag, you
can invoke SOAP-based web services deployed in your application server or anywhere
on the Internet. Objects returned by a web service are automatically
deserialized into ActionScript objects. Similarly ActionScript objects passed
as arguments to a web service operation are serialized according the WSDL description.
Notice that this example also added DataGrid column definitions (using DataGridColumn).
The BlazeDS server is not required to use the WebService. By default, the
application tries to connect directly to the domain specified in the WebService wsdl attribute. This will work
if one of the two conditions below is satisfied:
wsdl attribute is the domain from
which your application was downloaded. wsdl attribute. More information on crossdomain.xml is available here. If you want your application to access services available on another domain
without deploying a crossdomain.xml file on that domain (for example, because
you may not own the target domain), you can set the useProxy attribute of the WebService to true as in this example. In this case, the request is sent to the BlazeDS proxy,
which makes the request to the target domain on the client application's behalf.
This configuration also provides more control over the access to the service.
For example, you may configure the proxy to require authentication before
accessing a service, log access to the service, and so on.
When using the proxy, you can specify a logical name in the WebService destination attribute instead of specifying a hardcoded value in the wsdl attribute. You then map this
logical name to an actual URL in the WEB-INF\flex\proxy-config.xml file. Open this
file to see how the ws-catalog destination is configured.
Flex supports both RPC-encoded and document-literal web
services. Like HTTPService, WebService calls are asynchronous; you can set up result and fault event handlers.