Hi again,

I have had the luck of meeting Ryan Frishberg, who helped me out 
understanding the cause for the null.
Ryan told me to put a breakpoint at the start of this function so we 
could see the variables at the moment of the function call.
It seems that the result comes in the format of a XMLList and the 
_getPeopleByFirstLastName_populate_results function (below) tries to 
evaluate the result as an ArrayOfPerson which extends ArrayCollection. 
Because the result doesn't evaluate to be of data type ArrayOfPerson, 
null goes into the e.result, which is then sent to my handler function.

As my partner believes he is writing standard compliant SOAP code, and 
this method fails to work as expected, I would appreciate it if anyone 
could give me hint on how to solve this issue. Just to recall, our 
objective is to pass object arrays from SOAP into Flex.

Thanks in advance.
Telmo Dias



private function 
_getPeopleByFirstLastName_populate_results(event:ResultEvent):void
{
        var e:GetPeopleByFirstLastNameResultEvent = new 
GetPeopleByFirstLastNameResultEvent();
        e.result = event.result as ArrayOfPerson;
        e.headers = event.headers;
        getPeopleByFirstLastName_lastResult = e.result;
        dispatchEvent(e);
}





Telmo Dias wrote:
> Hi all,
>
> First of all , I'm new to flex. Already bought a few books but none 
> describes this issue in detail.
>
> I'm having huge trouble accessing object arrays from SOAP.  I'm using 
> Flex Builder 3, Version: 3.0.190133, the last beta version.
> I used the Import Web Services wizard to import 
> http://ws.marcocova.com/SOAP/af4.php?wsdl . My partner who writes the 
> SOAP code, has tried several approaches. In the approaches before the 
> current one, I couldn't even get a simple var, it would always come in 
> as null. Now I can get simple vars like strings or numbers, but I'm 
> unable to get Arrays.
>
> Below is the code I'm using. At this moment when I debug I'm getting the 
> error:
>
> TypeError: Error #1009: Cannot access a property or method of a null 
> object reference.
>     at WSDL8_AF4/processResults()[F:\Para_Novo_CD\BACKUPS\My 
> Documents\Flex Builder 3\WSDL8_AF4\src\WSDL8_AF4.mxml:32]
>     at flash.events::EventDispatcher/dispatchEventFunction()
>     at flash.events::EventDispatcher/dispatchEvent()
>     at 
> com.marcocova::ExampleService/_getPeopleByFirstLastName_populate_results()[F:\Para_Novo_CD\BACKUPS\My
>  
> Documents\Flex Builder 3\WSDL8_AF4\src\com\marcocova\ExampleService.as:147]
>     at flash.events::EventDispatcher/dispatchEventFunction()
>     at flash.events::EventDispatcher/dispatchEvent()
>     at 
> com.marcocova::BaseExampleService/processResult()[F:\Para_Novo_CD\BACKUPS\My 
> Documents\Flex Builder 
> 3\WSDL8_AF4\src\com\marcocova\BaseExampleService.as:207]
>     at 
> mx.rpc::AsyncResponder/result()[E:\dev\flex_3_beta3\sdk\frameworks\projects\rpc\src\mx\rpc\AsyncResponder.as:73]
>     at 
> mx.rpc::AsyncRequest/acknowledge()[E:\dev\flex_3_beta3\sdk\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:81]
>     at 
> DirectHTTPMessageResponder/completeHandler()[E:\dev\flex_3_beta3\sdk\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:387]
>     at flash.events::EventDispatcher/dispatchEventFunction()
>     at flash.events::EventDispatcher/dispatchEvent()
>     at flash.net::URLLoader/onComplete()
>
>
> Can someone who understands this, please help me? I've been around this 
> issue for one week without results... Already checked the posts on the 
> list, since 14/11/2007.
>
> Thanks in advance.
>
> Telmo Dias
>
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
> layout="absolute" initialize="getResults()">
>     <mx:Script>
>         <![CDATA[
>             import com.marcocova.*; //classes resultant from the wizard
>             import mx.collections.ArrayCollection;
>             import mx.utils.ArrayUtil;
>            
>             public function getResults():void{
>                 var myService:ExampleService = new ExampleService();
>                   //* Step 2: for the desired operation add a result 
> handler (a function that you have already defined previously) 
>                   
> myService.addgetPeopleByFirstLastNameEventListener(processResults);
>                   //* Step 3: Call the operation as a method on the 
> service. Pass the right values as arguments:
>                   myService.getPeopleByFirstLastName('*','*');
>                  
>             }
>            
>             public function 
> processResults(res:GetPeopleByFirstLastNameResultEvent):void{
>                 trace(typeof res.result); //this outputs object
>                 for (var x in res.result){
>                     trace(typeof x);//doesn't even trace once
>                 }
>                 var arrRes:ArrayCollection = res.result;
>                 var arrPerson:Array = arrRes.toArray();
>                 var pers:Person = Person(arrPerson[0]);
>                 trace(pers.firstName); //nothing either
>             }
>         ]]>
>     </mx:Script>
> </mx:Application>
>
>   
-- 
Telmo Dias <[EMAIL PROTECTED]>
XYLE   [Xyledot Unipessoal Lda.]
R. Dr. Jose Martinho Simoes, 81
3260-421 Figueiro dos Vinhos - Leiria - Portugal
Website   > www.xyle.pt
Tel/Phone > +351236551671
Tlm/Cell  > +351918047464
_________________________________________________

Nota de confidencialidade:  Esta mensagem poderá conter informação priveligiada 
e confidencial destinando-se exclusivamente ao destinatário da mesma. Se não é 
o destinatário da presente comunicação, agradecemos que nos informe e elimine a 
mensagem sem que a mesma seja divulgada, distribuida ou copiada. Obrigado.

Reply via email to