Using webService In Flex 3.0 Application
Flex 3.0 provides the easiest way to use the web services. Under the ‘Data’ Menu on your Flex Builder IDE there is a submenu namely ‘Import Web Service(WSDL)’,We can use it to Directly use the Web Services.Just create a Flex Project. No need to chose any ’Applciation Server Type’ under ‘Server Technology’ title. After that just go to the Import Web Service(WSDL)’ under ‘ Data’ menu.
After clicking on this you will see like below.
Just click on the ‘Next’ button.
Now you have to enter your webService url in the box with label ‘WSDL URI‘,and after that just click on the ‘Next’ button.
Here you can change the service if you are having more than one service. Also you can change package.If you don’t want just click on ‘Finish‘. After you will click on the ‘Finsh’ button you will find a folder ‘generated’ under your ’src’ folder in your application. Under this ‘generated’ folder there you will saw a ‘webservice’ folder. Just open it and find the total conversion of your webservice in now action Script 3. Just open the ‘Service.as’ file you will find how to use these classess for retreving results from your WebService. I am just telling you the way of using it via MXML tags,you can also use these with action script. Just copy and paste the code below in you Application file,and run it to find out the result.
*******************************************************************************************
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”horizontal”
xmlns:myService=”generated.webservices.*”>
<mx:Script>
<![CDATA[
import generated.webservices.*;
private var number1:int;
private var number2:int;
private function f1():void
{
number1=(int)(txtInput1.text);
number2=(int)(txtInput2.text);
}
]]>
</mx:Script>
<myService:Service id=”myService”>
<myService:multi_request_var>
<myService:Multi_request/>
</myService:multi_request_var>
</myService:Service>
<mx:VBox width=”50%” horizontalAlign=”center”>
<mx:HBox width=”100%” horizontalAlign=”center”>
<mx:Label width=”150″ text=”Enter First Number”/>
<mx:TextInput id=”txtInput1″ width=”100″ height=”30″ change=”f1()”/>
</mx:HBox>
<mx:HBox width=”100%” horizontalAlign=”center”>
<mx:Label width=”150″ text=”Enter Second Number”/>
<mx:TextInput id=”txtInput2″ width=”100″ height=”30″ change=”f1()”/>
</mx:HBox>
<mx:Button id=”myButton” label=”Call WebService” click=”myService.multi(number1,number2)”/>
<mx:Label id=”l1″ text=”{isNaN(myService.multi_lastResult)? ”: myService.multi_lastResult}” width=”150″/>
</mx:VBox>
</mx:Application>
*****************************************************************************************
Hope you will enjoy it……
Enjoy Flexing……………………..















