How Can I get Remote Objects to return XML in E4X?
-
08-07-2019 - |
Question
I'm writing a Flex application that makes full use of BlazeDS to a Java server. I use Remote Objects a lot, but I've come across an instance where receiving XML is cleaner and faster than returning objects.
Returning XML through BlazeDS is easy enough. I'm building up the XML with Dom4j on the Java and returning the root element through the BlazeDS service. BlazeDS translates the Dom4j objects into XML for me.
When receiving this objects on the Flex side, there are all ObjectProxy objects rather than XML. I've seen this before in a HttpService call, and to fix that I changed the resultFormat to E4X.
However, I cannot set a resultFormat on a RemoteObject service call.
Is there anyway I can convert these ObjectProxies into the E4X formatted XML?
Solution
Also, if you return XML either as a String or as some formal XML type then you can convert that to an XML object on the client side in Flex.
OTHER TIPS
To answer your question:
With the Remoting Service, you often use an AMFChannel. The AMFChannel uses binary AMF encoding over HTTP. If binary data is not allowed, then you can use an HTTPChannel, which is AMFX (AMF in XML) over HTTP.
and
http://livedocs.adobe.com/blazeds/1/javadoc/flex/messaging/io/amfx/package-summary.html
The data format of RemoteObject is binary AMF so maybe you should use the WebService or HTTPService class instead if you want to work with XML (AMF would be faster; perhaps you lose the speed if you work with XML - not sure about AMFX).
LiveCycle also seems to have a similar serializer:
Hope some of that mess helps.