Question

Has anyone used ADO.NET Data Services as a data source for Adobe Flex applications? If so, any success stories or tragedies to avoid? If you did use it, how did you handle security?

Was it helpful?

Solution

I use WebORB for .NET to do Flex remoting and then use DLINQ on the server. One tricky thing about using LINQ with WebORB is that WebORB uses Reflection to automatically retrieve all the relationships of the object(s) you return to Flex. This causes severe time penalties as LINQ uses lazy loading to load relationships. To prevent this from happening, I do something like the following:

Override your DataContext's constructor and add the following code:

this.DeferredLoadingEnabled = false;
DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith<Order>(q => q.Payments);
dlo.LoadWith<Order>(q => q.Customer);
this.LoadOptions = dlo;

This tells the DataContext to disable deferred loading of relationships and specifically instructs it to load just the relationships you want, without lazy loading. That way, WebORB isn't causing any lazy loading to happen through Reflection and the number of relationships being transferred to Flex is kept at a minimum.

Hope this helps you in some way. It's definitely one of those little "gotchas" when working with Flex/WebORB and LINQ.

OTHER TIPS

Yes, we use Flex with .Net web services extensively.

Flex can't handle .Net DataSets, or indeed much by way of complex xml types. We found that it was best to keep to relatively simple xml output.

However, if you do that, it can handle .Net web service output fine:

<mx:WebService id="myDataService" showBusyCursor="true">
    <mx:operation name="WebMethodName" 
                  resultFormat="object" 
                  result="functionFiredOnComplete();">
</mx:operation>
</mx:WebService>

public function load():void
{
    myDataService.loadWSDL( "web method's wsdl" );
    myDataService.WebMethodName.send( params );
}

public function functionFiredOnComplete():void
{           
    // get data
    var myData:Object = myDataService.WebMethodName.lastResult;
    ...

He Asked about ADO.NET Data Services not web service

Flex can only do GET and POST Flex doesn't understand HTTP Response messages

So in order to have Flex talk to ADO.NET data services you either have to;
1. use a proxy server, but you have to find or build one yourself
2. modify the incoming requests and use $method=MERGE and so on (same as proxy)
3. use another as3 httpService client, there are some opensource initiatives

Then you have to find out how to post data, and it cost a lot of time when you want to create a new record with JSON and specify a Id wich has a link to another table. This because you can't just update the integer, but instead you have to create a link string, it's feels not really easy.

So ofcourse it can be done, but out of the box you really have to make it yourself. I know that Flash Builder 4 will come with a REST import, this could speed up things, but hve no experience for that

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top