3 Replies Latest reply on May 21, 2007 12:45 PM by dzlmbq

    WebService in AS

    Hugo_Core Level 1
      Hellooooo you flexers

      Well, i have created an WebService in AS, because in the mxml tag way, the WSDL derived from an TextInput does NOT WORK.. :( sad... so i create this simple AS but i cant get the lastResult successful, Always give me null in the beginning, click again, and then the result, and for last [Object Object], can you light me :P ?


      [Bindable] public var webService:WebService = new WebService;

      public function wsHelloWorld():void{
      webService.wsdl = myWsdl.text;
      webService.loadWSDL();
      webService.HelloWorld(myInput.text);
      trace(webService.HelloWorld.lastResult);

      }



      null
      Hello, testee (--> This is the THING!!)
      [object Object] (--> named HelloWorldResponse Object)


      Hope you can help on this,
      Grate for all the help!

      Hugo Core
        • 1. Re: WebService in AS
          Hugo_Core Level 1
          anyone?
          • 2. Re: WebService in AS
            jlingwai Level 1
            This is how i have my webservice in AS....hope it helps


            public function mapData(bindFunction:Function):void{
            DataOp = new AbstractOperation();
            wsData = new WebService();
            DataBindFunction = new Function();
            wsData.wsdl = myWsdl.text;
            wsData.useProxy = false;
            wsData.loadWSDL();

            DataBindFunction = bindFunction;
            DataOp = wsData.getOperation("Run_WS_Method1");
            DataOp.addEventListener("result",mapData_Listener);
            DataOp.send();
            }

            public function mapData_Listener(event:ResultEvent):void{
            var serviceData:XML = new XML(DataOp.lastResult);
            process_Data(serviceData);
            }

            public function process_Data(data:XML):void{
            var tmpData:ArrayCollection = new ArrayCollection();
            for(var i:int = 0; i < data[0].SPs.length(); i++){
            var tmpObject:Object = {
            id: data[0].SPs .EmployeeID,
            firstName: data[0].SPs
            .FirstName,
            lastName: data[0].SPs .LastName,
            index: i
            };
            tmpData.addItem(tmpObject);
            }
            DataBindFunction(tmpData);
            }
            • 3. Re: WebService in AS
              dzlmbq
              The default resultFormat on the operation is object. Try creating the WS in mxml and set the resultFormat="xml" on the operation.

              <mx:WebService id="wsBlogAggr"
              wsdl=" http://localhost:8080/aWebService/services/NoArgsSimple?wsdl">
              <mx:operation name="getAnswer" resultFormat="xml">
              <mx:request/>
              </mx:operation>
              </mx:WebService>