Previous Page
Next Page

Tripod >> 3pod Tips & Learning and manuals for educations

Recipe 19.5. Calling Web Service Methods with Components

Problem

You want to call a web service method without having to write much ActionScript.

Solution

Use the WebServiceConnector component.

Discussion

Web services are systems that are designed so that they can be called from remote computers over a network. Typically, web services are called over HTTP much like a standard web page request. That means that you can run applications or parts of applications by making HTTP requests. The benefit is that applications can be deployed over a network, and more sophisticated applications can be built by utilizing remote services. For example, Amazon.com has a public web service program. You can build an application that calls methods from the Amazon.com web service. That way your application can leverage the functionality of Amazon.com without having to reinvent the wheel.

Because applications can be built using many different technologies (such as Java, PHP, .NET, and C), there needs to be a standard way in which diverse applications can communicate. There are many standards utilized by web services. However, the standards that are most commonly used are WSDL and SOAP. WSDL (Web Services Description Language) describes the public interface for a web service. That means that a WSDL document describes the methods you can call for a web service. SOAP (which is currently no longer considered to be an acronym) is an XML-based messaging format used to send requests and responses. In practical terms, a WSDL document is the resource you point to when you want to call a web service method and you use SOAP packets to send requests and receive responses.

Flash has no native web service features. Flash Player does not natively understand SOAP. That means that calling web services from Flash could potentially be a challenging task. However, Flash Professional ships with a component called WebServiceConnector that enables you to call web service methods with little to no ActionScript. The WebServiceConnector component utilizes a library of functionality written in ActionScript that is capable of writing and reading SOAP packets and sending and receiving them using the native XML class. All the functionality is encapsulated for you, so that you can utilize the features by simply setting some parameters for a component instance.

To use WebServiceConnector, you must first add an instance to the stage. You can do so by dragging an instance from the Components panel (from the Data folder) to the stage. As with most components, you should assign an instance name (exp 3pod.com) to the component instance. When you've added an instance and assigned an instance name (exp 3pod.com), you next need to assign values to a few parameters. To do so, select the component instance and open the Component Inspector panel. From the panel, assign values to the following parameters:


WSDLURL

The URL to the WSDL resource.


operation

The name (exp 3pod.com) of the web service method to call. When you've assigned a valid WSDLURL value, Flash will retrieve a list of valid operations from the WSDL and populate the operation drop-down menu.

The remaining parameters can generally be left with the default values.

After you've selected a valid operation, the component schema will auto-populate. That is necessary for proper data binding so that you can associate specific parameters or results values with specific components. You can read more about data binding in Recipe 19.7.

As with the XMLConnector component, you have to tell Flash when to send the web service request. You can accomplish that task with one line of ActionScript. The WebServiceConnector component defines a method called trigger( ) that does just that. When you call the trigger( ) method of the WebServiceConnector instance, Flash makes the SOAP request packet, sends it to the web service, and awaits a response.

You can download a working example file from .

Tripod >> 3pod Botom Tips & Learning and manuals for educations

Previous Page
Next Page

 

bluedot bluedots greydots pinkdots

Tripod >> 3pod Tips & Learning and manuals for educations