Flex & WebServices

302 views Asked by At

We have a Flex application which relies heavily on data driven content supplied via asp.net. Currently the majority of this data is provided via asp.net objects which are then XML serialised and sent via a simple ASHX handler. This is then parsed via e4x in singleton classes to populate either its self or arrays of sub classes which are then available to the rest of the application without making additional data calls.

This works but is it the best way? I've read quite a few articles discussing the subject but couldn't really find any consensus.

Should I look into converting these to Web Services? If so, how should I manage the bindings, automatically import them via Flex or build my own? What are the pro's and con's. An important factor in this decision is speed, lowest latency and highest throughput is essential

As a separate matter our application doesn't sit at the root of the domain, and when in local development makes data calls to our development servers. As a result we add flash vars to the application to specify the appRoot which is then appended to the service url as necessary.

MyService.url = GeneralData.ApplicationRootUrl + "Services/foobar.ashx";

Is this the best way? I have since discovered the rootURL property, should I be using this, how does it work in this context? If I were to convert the services to web services how would I go about implementing the same functionality to allow local development?

Many thanks

2

There are 2 answers

0
Akash Kava On

Flex Application is always loaded in browser, and you can use relative URL, so that your application will connect to same server from where it is loaded.

MyService.url = "/Services/foobar.ashx";

"/" will certainly append host where it came from. And it is always good practice to connect to same host where the flash is loaded from.

Secondly, SOAP web services use xml serialization, so if you use your handler to do e4x serialization or you use SOAP web service generator of Flash Builder, speed will be almost same. SOAP web service will certainly be little slower, but the difference will be in micro seconds to milli seconds.

However, with Web services, your development will speed improve as you will not have to create proxy classes.

1
JeffryHouser On

This works but is it the best way?

Best is very subjective based on your situation. If at all possible, I would recommend you use an AMF gateway. That way your objects can immediately convert from server side objects (.NET Classes) to client side objects (AS3 classes). This is a big time savings because you don't have to manually create your XML on the back end, nor manually process it in the front end. Also the binary format of AMF is going to give much smaller packets than XML or a SOAP WebService would.

For .NET AMF options, I'd look into WebORB or FlourineFX