3 Replies Latest reply on Nov 5, 2006 12:02 PM by Peter Lorent

    Deserialize an array of objects from a web service

    Level 7
      Hi, I'm calling a webservice method which returns an array of objects (let's
      say classes called MyClass).

      I now want to define a class in actionscript called MyClass which matches
      the properties of the class defined in the web service (written in .NET),
      call the webservice method, and then deserialize the result in actionscript
      into an array of type MyClass.

      The code I have so far is:

      import mx.services.WebService;
      import mx.services.Log;

      var mylog:Log = new Log(Log.DEBUG);
      myLog.onLog = function(txt) {
      trace(txt);
      };

      var ws:WebService = new WebService(wsc.WSDLURL);

      ws.onLoad = function(wsdl) {
      MyPendingCallObject =
      ws.CallTheWebServiceMethodWhichReturnsAnArrayOfMyClasses();
      MyPendingCallObject.onResult = function(result)
      {
      trace(result);
      // HOW CAN I DESERIALIZE the result parameter into an Array of
      MyClass ???
      }
      MyPendingCallObject.onFault = function(fault)
      {
      trace('FAULT! ' + fault.faultCode + "," + fault.faultstring);
      }
      };

      // If the WSDL fails to load the onFault event is fired.
      ws.onFault = function(fault) {
      trace(fault.faultstring);
      };

      TIA