Hi Tracy,
Here is what I found in Flex SDK source. I hope it will clarify the
event.result mystery a bit:
flex_sdk_3/frameworks/projects/rpc/src/mx/rpc/soap/SOAPDecoder.as
Line 306:
else if (resultFormat == "e4x")
{
// Return the children as an XMLList.
soapResult.result = bodyXML.children();
}
When I run my application in the Flex debugger (I use fdb here), I see
that event.result is XMLList:
Breakpoint 23, decodeEnvelope() at SOAPDecoder.as:285
285 var bodyXML:XML =
responseXML[soapConstants.bodyQName][0];
(fdb) n
287 if (bodyXML == null || bodyXML.hasComplexContent()
== false || bodyXML.children().length() <= 0)
(fdb)
294 var faultXMLList:XMLList =
bodyXML[soapConstants.faultQName];
(fdb)
295 if (faultXMLList.length() > 0)
(fdb)
302 if (resultFormat == "object")
(fdb)
306 else if (resultFormat == "e4x")
(fdb)
309 soapResult.result = bodyXML.children();
So, when I print event.result in my result handler, I see
(fdb) p *event.result
$1 = result = [Object 159761505, class='XMLList']
0 = [Object 160100257, class='XML']
I wish I had XML class source code. It would be interesting to look
how XML() is implemented. It is defined in Global.as, but no actual
source is there:
public native function XML(expression:Object):XML
- Mykola
--- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Odd that the "as" operator is not working correctly for you.
>
>
>
> I'd use the XML() syntax. Having the type be XMLList when it is
> actually an XML node might confuse someone some day. But its not my app.
>
>
>
> Perhaps someone else will have some input on the data type issue
>
>
>
> Tracy
>
>
>
> ________________________________
>
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Mykola
> Sent: Friday, March 21, 2008 3:23 PM
> To: [email protected]
> Subject: [flexcoders] Re:Help binding an XML file from a webservice?
>
>
>
> Hi Tracy,
>
> I don't really want to disagree with you, but it is a technical issue
> and I see some difference in what you said and my code results. Maybe
> you will know the answer.
>
> > E4x event.result is XML.
>
> I am actually getting xml (lowercase) type, not XML type. When I run
> typeof on my event.result:
>
> trace("result type: " + (typeof event.result));
>
> I am getting this line in the log:
>
> result type: xml
>
> For some reason, it is lowercase xml type.
>
> If event.result is XML, then casting of event.result to XML should
> work, right? For some reason, it does not really work:
>
> var xmlres:XML = event.result as XML;
> trace("xml result: " + xmlres);
>
> # flashlog.txt contains:
> xml result: null
>
> Why am I getting null?
>
> By the way, if I cast it to XMLList, I am getting an object that is
> not null.
>
> var xmllstres:XMLList = event.result as XMLList;
> trace("xmllstres result: " + xmllstres);
>
> # flashlog.txt contains:
> xmllstres result: <m:getProductsResponse
> xmlns:m="http://org/wssample/service <http://org/wssample/service> "
> xmlns:env="http://schemas.xmlsoap.org/soap/envelope/
> <http://schemas.xmlsoap.org/soap/envelope/> ">
> <m:return xmlns:java="java:org.wssample.product">
> <java:ProductDetails>
> <java:ModelName>Blue-Ray DVD Player</java:ModelName>
> <java:ModelNumber>BPL051</java:ModelNumber>
> </java:ProductDetails>
> ...
>
> I can wrap event.result in XML object and it gives me an object that
> is similar to xmllstres.
>
> var xmlres2:XML = XML(event.result);
> trace("xml result 2: " + xmlres2);
>
> # flashlog.txt contains:
> xml result 2: <m:getProductsResponse
> xmlns:m="http://org/wssample/service <http://org/wssample/service> "
> xmlns:env="http://schemas.xmlsoap.org/soap/envelope/
> <http://schemas.xmlsoap.org/soap/envelope/> ">
> <m:return xmlns:java="java:org.wssample.product">
> <java:ProductDetails>
> <java:ModelName>Blue-Ray DVD Player</java:ModelName>
> <java:ModelNumber>BPL051</java:ModelNumber>
> </java:ProductDetails>
>
> Once again, I did not mean to disagree with what you said. I just want
> to clarify things.
>
> Thank you,
> - Mykola
>
> --- In [email protected] <mailto:flexcoders%40yahoogroups.com>
> , "Tracy Spratt" <tspratt@> wrote:
> >
> > E4x event.result is XML. But the division between XML and XMLList is
> > blurred, since most XML methods will work on an XMLList that has only
> a
> > single node.
> >
> >
> >
> > Tracy
> >
> >
> >
> > ________________________________
> >
> > From: [email protected] <mailto:flexcoders%40yahoogroups.com>
> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of Mykola Dzyuba
> > Sent: Friday, March 21, 2008 2:40 AM
> > To: [email protected] <mailto:flexcoders%40yahoogroups.com>
> > Subject: [flexcoders] Re:Help binding an XML file from a webservice?
> >
> >
> >
> > Hi,
> >
> >
> >
> > Your code looks mostly right. Just a couple of updates. You need to
> > define namespaces as you see in your SOAP response. Also, it might be
> > different in your case, but I think event.result in e4x mode is
> XMLList,
> > not XML. Can you add this line to your handleGetSpecies method to see
> > the actual type?
> >
> >
> >
> > trace("result type: " + (typeof event.result));
> >
> >
> >
> > Somebody asked a similar question a couple of days ago. You might want
> > to check this post:
> >
> >
> >
> > http://tech.groups.yahoo.com/group/flexcoders/message/106748
> <http://tech.groups.yahoo.com/group/flexcoders/message/106748>
> > <http://tech.groups.yahoo.com/group/flexcoders/message/106748
> <http://tech.groups.yahoo.com/group/flexcoders/message/106748> >
> >
> >
> >
> > - Mykola
> >
>