20.24. Consuming Web Services with Flash Remoting for .NET or ColdFusion

Problem

You want to consume a web service using Flash Remoting for .NET or ColdFusion.

Solution

Use a Flash Remoting service object that maps to the .wsdl file for the web service and invoke the web service method from the service object.

Discussion

One of the great features of Flash Remoting for .NET and ColdFusion is that you can use it to invoke web service methods directly from the Flash movie. You don’t have to create any server-side scripts to consume the web service and return the results to Flash.

The process for calling a web service method from a Flash movie is the same as calling any service function using Flash Remoting. You need to create a connection object, a service object, and a response object. Then, you only need to invoke the service function from the service object and tell it to return the results to the response object. The only change when working with web services (versus service functions) is that you should map the service object to the web service’s WSDL (Web Services Description Language) document. You should still use your local application server as the Flash Remoting gateway, regardless of the domain of the web service. Your local application server actually proxies the request for you. For example:

// Create a connection object that uses your local application server // as the Flash Remoting gateway. gwURL = "http://localhost:8500/flashservices/gateway"; NetServices.setDefaultGatewayUrl(gwURL); ...

Get Actionscript Cookbook 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.