views:

686

answers:

4

Why are there two different HTTPService classes in Flex? this and this

And the second one inherits the first one. Why couldn't there be a single class combining the two?

+3  A: 

One of the objects (the first link you posted) is the HTTPService Object itself.

The second is the object that wraps the HTTPService object and gives it the additional functionality for the <mxml /> tag.

The two probably weren't combined because you don't necessarily need the implementation of the IMXMLObject and IMXMLSupport interfaces every time you need an HTTService object.

Justin Niessner
+1  A: 

mx.rpc.http.mxml.HTTPService can also handle concurrency while the other can't.

Edit:

Although in the online documentation I see concurrency as a property of both, several sources say thats not true(and my tests didn't work when I first tried using it). Also the concurrency package is only imported into the mxml.HTTPService, not the base rpc class.

Bug Comment Mederator comment on the docs page

ryanday
Any source for this information?
dta
Yes, but sporadic. http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_2.htmlPlease scroll to the moderator wvxvw's comment. Also https://bugs.adobe.com/jira/browse/FLEXDOCS-217Also if you look in the source, rpc.mxml.Concurrency is imported into mx.rpc.mxml.HTTPService while its not imported into the other. I agree that the documentation isn't very helpful here though.
ryanday
A: 

The first is a member of the mx.rpc.http package and is used in ActionScript code. The other version of the HTTPService class is a sublass of the first and is a member of the mx.rpc.http.mxml package. This is the version you use when you instantiate the object with the tag.

The versions are nearly identical with two significant differences: only the MXML Version implements the showBusyCursor property, which casuses an animated curser top be displayed for the duration of an HTTPService request/response cycle, and the concurrency property, which determines how multiple concurrent requests to the same network resource are handled.

The concurrency property isn't implemented in the version of the HTTPService class typically used in ActionScript because, when using ActionScript you commonly create a new HTTPService object for each new request.

Source: Adobe Flex 3 Bible - David Gassner

PDXNative
+1  A: 

There appear to be more error handling features in the URLLoader class. Using MXML to create your HTTPService is not a big difference though.

// ActionScript Style
private function myService():void {
   var service:HTTPService = new HTTPService();
...service.parameters = value;...
   service.send();
}

or

< !-- MXML Style -- >
< mx:HTTPService >
...< parameters >...
< /mx:HTTPService >
Dylan