×
Namespaces

Variants
Actions

Archived:How to access WebServices using WebServiceConnector component

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.

Article Metadata
Article
Created: mfabiop (11 Jun 2008)
Last edited: hamishwillee (14 May 2013)


In this tutorial, we will show how to access a web service easily using the WebServiceConnector component.

First of all, you've to had a web service started. We'll use a public web service to get current weather and weather conditions for major cities around the world. More details about this WebService can be view in [1]

Now, let's code the client.

  • You've to create a instance of WebServiceConnector into the Stage. Give it a instance name and set the WSDLURL field in Parameters panel.
  • Set the following fields in the parameters panel of WebServiceConnector instance:
    • WSDLURL: The url of the WSDL file location (local or remote).
    • operation: The name of the operation to be called.
  • You also have to create a UIComponent to show the recovered data from the WebService. In our example, we,ll use four labels. Like showed in the Figure.

Weather example.PNG

In the first frame of the timeline you have to add the following code:

fscommand2("Fullscreen",true);
//Here is created a 'wslistener' object that will be a event listener of the
//WebServiceConnector object. The event name is 'result'
 
var wslistener:Object = new Object();
 
wslistener.result = function(evt:Object){
 
location_txt.text = "Processing...";
time_txt.text = "Processing...";
sky_txt.text = "Processing...";
temperature_txt.text = "Processing...";
 
var result_xml = new XML();
result_xml.ignoreWhite = true;
 
result_xml.parseXML(evt.target.results);
location_txt.text = result_xml.childNodes[0].childNodes[0].firstChild.nodeValue;
time_txt.text = result_xml.childNodes[0].childNodes[1].firstChild.nodeValue;
sky_txt.text = result_xml.childNodes[0].childNodes[4].firstChild.nodeValue;
temperature_txt.text= result_xml.childNodes[0].childNodes[5].firstChild.nodeValue;
}
 
//We've to add the 'wslistener' object as a listener to 'weather_ws' object.
//When the operaion is finished, the 'wslistener.result' method will be invoked.
weather_ws.addEventListener("result",wslistener);
 
//When the button is pressed, the Web Service must be invoked.
get_btn.onPress = function(){
//The 'params' attribute receives an Array in the same order of the schema
//defined in WebServiceConnector compoent.
//Window -> Component Inspector -> Schema
weather_ws.params = [city_txt.text,country_txt.text]
weather_ws.trigger();
}
  • Start the emulator or put the swf in the mobile phone.


Remember to put the SWF file in the \Others\Trusted folder if you want to use Flash Lite 3.0.


Further reading

This page was last modified on 14 May 2013, at 09:01.
149 page views in the last 30 days.