Web services are all the rage these days. At least that's what I hear. After reading this tutorial, I dabbled with web services in Flash myself. If you would like to get an idea of what kind of web services are available, take a look around XMethods. Unfortunately, not all of them will work with Flash. It took me a few tries to find that one that does. I ended up creating a little interface that uses a temperature conversion service. It converts Centigrade to Fahrenheit and vice versa. Nothing too impressive or elaborate, but this is just the tip of the ice berg.
All you need to know are the web service's method names and expected parameters. In the case of the temperature conversion service, the methods are ctoF and ftoC. Here is the ColdFusion code generated in Dreamweaver which tells you so:
<cfinvoke
webservice="http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter"
method="ctoF"
returnvariable="ctoFRet">
<cfinvokeargument name="temp" value="enter_value_here"/>
</cfinvoke>
<cfinvoke
webservice="http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter"
method="ftoC"
returnvariable="ftoCRet">
<cfinvokeargument name="temp" value="enter_value_here"/>
</cfinvoke>
In Flash, you call the ftoC method like so:
myService = gateway_conn.getService("http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter", this);
myService.ftoC({temp:your_inputfield_variable});
You then need to create an event method called ftoC_Result that is invoked when data is returned from the server. Check out the .fla for this example to see just how easy it is to connect to a web service. All you need is Flash Remoting, the wsdl URL -- in this case http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter -- and the method and parameter names the web service expects. Unfortunately, since I don't have a dedicated server at home and the server on which this website is hosted does not offer Flash Remoting, all I have to show for myself for now is a screenshot. 
|





posted
by Vera Fleischer (
