The WebServiceConnector Component


The WebServiceConnector Component

The webServiceConnector component is designed to easily and quickly connect to web services on the web. To use it, drag it onto the stage, set the URL for the web service's WSDL, select the web method you are going to call, and trigger it.

Data from the webServiceConnector comes back as an object, as you will see in the following example.

1.

Create a new Flash document.

2.

Drag an instance of the WebServiceConnector component onto the stage; give it an instance name of myConnector, set its WSDLURL parameter to http://localhost/hello.asmx?WSDL (because you put it in the Web Services panel, you can use the drop-down menu and choose it), and then set the operation parameter to sayHello (it will be the only choice in the drop-down).

3.

Drag an instance of the TextInput component onto the stage and give it an instance name of results_ti.

4.

Create a new layer called actions.

5.

In the first frame of the Actions layer, open the Actions panel and place this code in it:

 //create an object to listen for when the WebServiceConnector receives data var resultListen:Object = new Object(); //create the event for the listener resultListen.result=function (myResults) {     results_ti.text = myResults.target.results; } //add the event listener to the WebServiceConnector myConnector.addEventListener("result", resultListen); //connect to the web service myConnector.trigger(); 

The preceding code creates a listener object for the webServiceConnector component. It then creates an event callback, passing it one parameter, the myResults parameter, which will be the results coming back from the web service. We then add the event listener to the webServiceConnector and finally call the TRigger() method, which will activate the webServiceConnector.

When you test the movie, you will get the same result as before using this web service. This example just shows how simple it is to connect to web services using the webServiceConnector.

But what if it were simpler?




Macromedia Flash Professional 8 Unleashed
Macromedia Flash Professional 8 Unleashed
ISBN: 0672327619
EAN: 2147483647
Year: 2005
Pages: 319

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net