1 Reply Latest reply on May 4, 2007 5:20 AM by batmitra

    webservice and flex

    kanukukreja
      Hello,

      i’m trying to get a result from web services in flex but I’m not able to get it.

      And one more thing instead of writing this code in MXML file I want to write it in to a class and then call it.

      Will you please help me out in this?

      Here’s my code:



      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" >



      <mx:Script>

      <![CDATA[



      import mx.rpc.events.FaultEvent;

      import mx.rpc.events.ResultEvent;

      import mx.rpc.Responder

      import mx.rpc.Fault

      import mx.rpc.soap

      import mx.rpc.soap.WebService

      import mx.rpc.soap.WSDL

      import mx.rpc.soap.LoadEvent

      import flash.events.EventDispatcher

      import mx.rpc.soap.Operation

      import flash.events.Event







      var webService:WebService = new WebService();



      webService.wsdl= " http://210.7.70.114/ws/poker.asmx?wsdl";



      webService.loadWSDL();



      webService.addEventListener(LoadEvent.LOAD, onWSDL);



      webService.addEventListener(ResultEvent.RESULT, onRes);



      webService.addEventListener(FaultEvent.FAULT,onFault);



      webService.StartUserGameSession("mo64uq12557030rlzkxo45jke3yszb")



      private function onRes(event:ResultEvent):void {

      trace("successful")

      }



      private function onFault(event:FaultEvent):void {

      trace("error")

      }







      ]]>

      </mx:Script>



      </mx:Application>






        • 1. Re: webservice and flex
          batmitra Level 1
          Hi
          Are you using .Net for your webservice?

          If yes, then if you are using framework 1, you can't deal with webservices directly on flex, but you can build an array of objects and return it to flex, on flex you have to build an arrayCollection with those objects received.

          Another thing , if you want to have results, you must have an operation name, wich is the name of your method on your webservice, and you must invoke your webservice something like mywebservice.myoperation()