5 Replies Latest reply on May 25, 2010 10:05 AM by Flex harUI

    Typecasting issue with inheritance

    Deeptid

      Hi

           I have an issue with inheritance. i have imported the wsdl and generated stubs in flex. The stubs generated has both the base and derived classes. Now when i tried calling a webservice method from flex which has return type of base class but returns a deriverd class object and when i tried to typecast it back to derived class at flex end it gives an error as :

       

      TypeError: Error #1034: Type Coercion failed: cannot convert valueObjects::Person@10d0ef99 to valueObjects.Employee.

       

          at intest/resultHandler()[C:\Documents and Settings\Administrator\Adobe Flash Builder 4\intest\src\intest.mxml:31]

       

          at flash.events::EventDispatcher/dispatchEventFunction()

       

          at flash.events::EventDispatcher/dispatchEvent()

       

          at com.adobe.fiber.services.wrapper::AbstractServiceWrapper/http://www.adobe.com/2008/flex/model/internal::propagateEvents()[C:\depot\DataServices\bra nches\lcds_modeler101\frameworks\projects\fiber-swc\src\com\adobe\fiber\services\wrapper\A bstractServiceWrapper.as:200]

       

          at flash.events::EventDispatcher/dispatchEventFunction()

       

          at flash.events::EventDispatcher/dispatchEvent()

       

          at mx.rpc::AbstractService/dispatchEvent()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\A bstractService.as:333]

       

          at mx.rpc.soap.mxml::WebService/dispatchEvent()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\ rpc\soap\mxml\WebService.as:267]

       

          at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\4.0.0\frameworks\pro jects\rpc\src\mx\rpc\AbstractOperation.as:254]

       

          at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\4.0.0\frameworks\projec ts\rpc\src\mx\rpc\AbstractInvoker.as:318]

       

          at mx.rpc::Responder/result()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:5 6]

       

          at mx.rpc::AsyncRequest/acknowledge()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\AsyncR equest.as:84]

       

          at DirectHTTPMessageResponder/completeHandler()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\ messaging\channels\DirectHTTPChannel.as:446]

       

          at flash.events::EventDispatcher/dispatchEventFunction()

       

          at flash.events::EventDispatcher/dispatchEvent()

       

          at flash.net::URLLoader/onComplete()

       

       

       

       

       

      while debugging the resultevent.result variable had attributes of only the base class but the massage.body has all the values of derived class in xml foramt.

      is there any workaround to obtain all the values of derived class in the resultevent.result variable or type cast it to derived class object?

       

      thanks and regards,

      -deepti