Import Web Service(WSDL) Wizard in Flex 3.0
Posted by shardulbartwal on March 20, 2008
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……………………..
















ali said
Dear first of thx a lot i its reallz nice exmple i have one wsdl file and flex3 also genenrate code for this but can u tell me what i have to do next how can i use first Login and password …..wsdl link than other wsdl to retrive data help me please i am very greatfull to you thanks
Alkan ARSLAN said
Thanks Shardul Singh Bartwal
Nayeli said
Hello… I’m having trouble importing a web service, every time I try I get the same error: Unable to load the WSDL. Specify another URI. I’m online… and everybody is able to import that web service, can you help me out? what can be wrong?? thanks
ngo tan cuong said
Thanks so much!
Salvador Bravo said
I have the same error as Nayeli, anybody have an idea of what could be happening?
Regards
SB
Shardul singh Bartwal said
Hi,
Salvador Bravo,
The only reason which i suppose is that you r not using wsdl with the url of your
webservice.Pls check the url of your webservice in the same format as mentioned above.
Thnx…….
Shardul S. Bartwal
Alkan ARSLAN said
text=”{isNaN(myService.multi_lastResult)? ”: myService.multi_lastResult}”
Problem
Olivier said
Hello and thanks for ur tutorial.
I’m trying to set up this kind of behavior but especillay with https web service. The problem I’m facing is that it does work well with HTTP normal WS and the wizard is telling me that he was unable to locate my WSDL file when using the HTTPS protocol.
I checked many posts and threads about the cross domain file but couldn’t fix it .
Do you have any idea ?
Olivier ROMAND
pulkit kaushik said
what is the of the option “import web service(wsdl)….”
info said
excellent flex example
Ram said
The following line got errors:
text=”{isNaN(myService.multi_lastResult)? ”: myService.multi_lastResult}”
Shardul Singh Bartwal said
It means myService.multi_lastResult is giving the value which is something undefined….