BTA Flexing

My passion RIAs…………..Shardul Singh Bartwal

Import Web Service(WSDL) Wizard in Flex 3.0

Posted by Shardul Singh Bartwal 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.

importwsdl.png

After clicking on this you will see like below.

importwsdl1.png

Just click on the ‘Next’ button.

importwsdl2.png

Now you have to enter your webService url in the box with label ‘WSDL URI‘,and after that just click on the ‘Next’ button. 

importwsdl3.png

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……………………..

Advertisements

20 Responses to “Import Web Service(WSDL) Wizard in Flex 3.0”

  1. 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

  2. Thanks Shardul Singh Bartwal

  3. 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

  4. ngo tan cuong said

    Thanks so much!

  5. Salvador Bravo said

    I have the same error as Nayeli, anybody have an idea of what could be happening?

    Regards
    SB

  6. 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

  7. Alkan ARSLAN said

    text=”{isNaN(myService.multi_lastResult)? ”: myService.multi_lastResult}”

    Problem

  8. 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

  9. pulkit kaushik said

    what is the of the option “import web service(wsdl)….”

  10. info said

    excellent flex example

  11. Ram said

    The following line got errors:

    text=”{isNaN(myService.multi_lastResult)? ”: myService.multi_lastResult}”

  12. Alex Dove said

    I have been working on a solution which appears like it would work fine. The source code and examples are found on Code Project http://www.codeproject.com/KB/aspnet/FlexASPWebService.aspx?msg=3270246#xx3270246xx This Flex/ASP example uses a web service to communicate to a SQL database. Flex makes a web service call to the .asmx file via WSDL and the magic happens. I am running into a roadblock as I receive an error that the app cannot find the WSDL. I have tried to run the same WSDL URL in a browser and I get an server application error.

    I also am getting an error when using the example posted here. When I place my URL into the WSDL URI text box I receive an error that Flex cannot find the WSDL.

    The Code for the Flex file is as follows…

    Any ideas?

  13. shardulbartwal said

    Hi…….
    Your flex file code is not included here.Pls add that.

  14. Olivier said

    Hi everyone,
    In case some of you were still facing problem with the importation of the WSDL in Flex, in particular with HTTPS the trick is that in the case of a self signed certificate (no idea for a real certif) flex builder won’t trust it.
    So you have to add it manually to the certificate repository of flex builder so it can then discuss with the server.
    In the flex builder directory there’s this file so called “cacerts” which has all the certificate that flex builder accepted. When I had to use it, I played with a class Java found on the web that allow to manually accept self signed certificate. This class also re created a new repository so that I could change the one from Flex Builder 😀
    You may want to look into that direction …
    Hope it might help
    Olivier ROMAND

  15. sunil Rana said

    thanks
    paji

  16. […] am accessing the WSDL file over HTTPS which is protected with a login and password but you can also test the intropection wizard with free available web services available on the […]

  17. I like the valuable information you supply in your articles. I’ll bookmark your weblog and check once more here regularly. I’m quite sure I’ll learn lots of new stuff right here! Good luck for the next!

  18. Everyone loves what you guys are up too. This sort
    of clever work and exposure! Keep up the terrific works guys I’ve included you guys to my personal blogroll.

  19. Hello there, I found your blog by the use of Google
    whilst searching for a similar matter, your web site got here up, it seems good.
    I’ve bookmarked it in my google bookmarks.
    Hi there, just was alert to your weblog thru Google, and found that it is really informative. I am going to be careful for brussels. I will appreciate for those who proceed this in future. A lot of other people might be benefited out of your writing. Cheers!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: