views:

1094

answers:

1

I have a WebService that returns XML in a SOAP response:

<?xml version="1.0" encoding="utf-8" ?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    <soap:Body>
        <GetConfigResponse xmlns="Web.Services">
            <GetConfigResult>
                <Configuration xmlns="">
                    <Stuff>False</Stuff> 
                    <MoreStuff>
                        <Report_Format>PDF</Report_Format> 
                        <Report_Sections>
                            <Report_Section>
                                <idNmb>1</idNmb> 
                                <name>Report 1</name> 
                                <isDefault>true</isDefault> 
                                <isVisible>true</isVisible> 
                            </Report_Section>
                            <Report_Section>
                                <idNmb>2</idNmb> 
                                <name>Report 2</name> 
                                <isDefault>false</isDefault> 
                                <isVisible>true</isVisible> 
                            </Report_Section>
                        </Report_Sections>
                    </MoreStuff>
                </Configuration>
            </GetConfigResult>
        </GetConfigResponse>
    </soap:Body>
</soap:Envelope>

When I call this WebService the Flex debugger shows the type of the ResultEvent.result is "ObjectProxy". When I try to cast this value as XML, it traces as "[object Object]", and I cannot access the XML nodes. For most other WebServices I call, the ResultEvent.result is of type "Array", and converts to XML with no problem.

What can I do to store this result as XML?

+1  A: 

Set the resultFormat of your request/operation to "e4x" and it will return an XML object instead of converting the result to an ObjectProxy.

ianmjones
I'm using AbstractOperation as the operation type in my base WebService Class. No resultFormat for the AbstractOperation Class. I will try changing this to mx.rpc.soap.Operation and see if it will still work correctly. Thank you.
Eric Belair
It worked! Thanks. So obvious, but I couldn't see it. Thank you ianmjones (and stackoverflow).
Eric Belair
This broke another WebService call I had - it wasn't handling namespaces correctly - so I had to change the resultFormat to "xml" for this to work across the board.
Eric Belair