views:

3421

answers:

7

I have been using Flex for a while and have not used remoting as of yet. Currently my apps use a webservice that generates xml that I use for databinding.

What would be the benefit to using remoting over an xml webservice in this use case? Is there a general guideline when I should choose remoting over webservices?

Why would I want to use remoting?

I have downloaded http://www.fluorinefx.com/, but have yet to do any real tinkering...

Thanks.

+2  A: 

Speaking personally I use remoting because I prefer AMF to SOAP/XML for the simple reason of speed and packet size.

Ted has a good discussion in the relative merits of XML vs. AMF here

Something to consider is what you have already in place on the server and where you think the future of your clients lies. Do you anticipate replacing or extending your clients? If yes then Web Services are a good architectural choice. If you are committing to Flex in the short/medium term then you may be able to squeeze better performance out of remoting with AMF3 vs. your web services.

P.S. I once had a link to a very good site which had measurements of the relative performance of AMF and SOAP - I'll see if I can find it and post a link.

P.P.S. here it is, but it seems not to be working at the moment.

Simon
+1  A: 

Remoting is meant to make the transfer of data from a remote service to a Flash or Flex app easier and faster. When using remoting there is no need to parse or deserialize the data received from the service. This is because data is sent to the application in native bytecode.

One of my main reasons to use remoting is that it is more lightweight than an XML service. This is because XML is a bad format memory-wise, especially for large data sets. XML is great as an exchange format, but once inside your application, due to the verbose tags and possible whitespace, will most likely consume more memory than values expressed in native bytecode.

Matt W
This is just plain wrong in every way. Remoting between Flash and Java say, involves serialising Flash objects as XML, passing them to the java server, which then deserialises that XML into Java objects. Native bytecode doesn't come into it.
David Arno
I beg to differ. If you're using a service that returns XML that has to be parsed, then you're not really taking advantage of what remoting can do for you. Use a remoting service that utilizes AMF. AMF is binary data that is transfered to the client as opposed to XML.
Matt W
Sure the data passed back and forth need not be XML, and as you say the data in AMF's case is binary. It is not Flash bytecode though. It is serialised data, ie the objects have to be encoded at one end and decoded at the other end. The data does have to be deserialised.
David Arno
Guys, but is AMF via Remoting faster than an XML Service? Definitive answer would be appreciated ;-)
defmeta
@defmeta, it'll depend on the size of the data you are passing back and forth. There is no one answer to this :)
David Arno
+3  A: 

Web services are great if you are only using simple data transfers between the client and host. You form up the XML message, send it to the server and get a simple XML message, back. You then deserialise it and act upon the data accordingly. AS3 support for XML is superb, you can use it to communicate with any data service and you are in full control at the client end.

Where web services fall down is when the data structures passed back and forth become too complex, or when the number of different data structures passed back and forth become too large. Remoting overcomes these problems by providing a heavyweight framework that handles the serialisation for you. Define your .NET/ PHP/ Java or whatever classes, and the framework should provide tools to generate the equivalent AS classes. That way you can send complex object structures back and forth without needing to know how the data is being serialised. Because you don't need to know, it can compress the structure to make it pretty much non-human-readable, or even use binary data so you get speed increases too.

Remoting is not suitable for small scale or varied server protocol stuff though. You have to synchronise class structures between server and client; you can only communicate with a compatible remoting servers and the framework adds overhead to the client size and complexity.

There is no right answer as to which to use, when. Both have advantages and disadvantages. As a rule of thumb though, use web services for simple stuff and remoting for complex stuff (which is pretty vague advice ;)

David Arno
A: 

If you plan to use the data on other applications (meaning that yours is only one of several frontends) you could use the XML otherwise you will save some time by using remoting.

Jeduan Cornejo
A: 

Also of note, once you start into this area a good wire protocol analyzer is invaluable. Two written specifically for flash protocols are Charles and Service Capture. I just purchased Service Capture, and have been very happy with it. It also has a great "bandwidth simulation" tool which helped when seeing how my pre-loader would look on lower bandwidth connections.

Marcus

A: 

This is a really good live benchmark test that compares AMF remoting with Web Services and HTTP Services. You can even download the source code to run this test in your own environment.

I'd also agree with some of the earlier posts that AMF remoting really shines when you are running large data sets. For smaller data sets you probably won't see a significant difference.

Kathleen Erickson
A: 

I want to send an email with HTTPService in Flex Data Services project but does not work the HTTPService, the form of mail function on a basic project but when I put in my application no longer works, I need help, thanks

Hiram