Tuesday, October 17, 2006

Calling a webservice in Flex 2

Making a webservice call in Action Script 3.0
Without using FDS

Flex webservice Sample.

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="creationCompleteHandler()" >

 <mx:WebService id="loginWS"

 

 wsdl="http://vishwajit/TestWS/Service1.asmx?WSDL"

  

 useProxy="false" 

 fault="wsFault(event)" >

 

 <mx:operation name="HelloWorld" result="HelloWorldResult(event)" 
>   


  </mx:operation>

 

 <mx:operation name="login" result="getLoginResult(event)"  >

    <mx:request xmlns="" >  

    <loginId>a1</loginId>

    <password>a1</password> 

   </mx:request>

  </mx:operation>

 </mx:WebService>

 

 

 <mx:Script>

  <![CDATA[

  import mx.controls.Alert;

  

  public function creationCompleteHandler()

  {

  

  

  loginWS.login.send();  

  //loginWS.HelloWorld.send();

 

  }

   

   

  public function HelloWorldResult(result : Object)

  {

   Alert.show("HelloWorldResult");

  }

   

   



  public function wsFault(fault:Object)

  {

   Alert.show(""+fault);

  }

   

  ]]>

 </mx:Script>

</mx:Application>




Time wasted/invested on the issue 2.5 Man days

2 comments:

Prem Sankar C said...

Hi am a beginner in flex .
i want to connect asp web service to flex . help me your code in not working contact me prems4u@gmail.com

java_soap_flex said...

If you interested in other simple example tutorial

http://programmaremobile.blogspot.com/2009/10/flex-as3-call-java-webservice.html