The compiler does some code-gen to make HTTPService
work. Is there a reason why you really want HTTPService used in AS-only? I'd
encourage you to read the preview chapter of the upcoming Flex book which talks
about writing a Service locator in MXML which I think would be sufficient for
your needs. The chapter is geared towards RemoteObject but the process would
be the same for HTTPService.
http://www.theserverside.com/articles/content/Flex/Flex_Chapter20.pdf
Matt
-----Original Message-----
From: Ryan Olson
[mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 01, 2004 2:09
PM
To: [email protected]
Subject: [flexcoders] Using
HTTPService in a pure AS class
Hi [again] flexcoders,
Is there a trick to using the HTTPService class in
a pure AS class, ie
without the mx:HTTPService tag? Everything seems
to work up until I
invoke send(), at which point nothing gets sent
(no HTTP debug output as
I get when using it through the MXML tag) and the
fault event fires
saying "Could not retrieve data". Here's
what I've got:
import mx.servicetags.HTTPService;
class PortfolioDAO {
var editService:HTTPService;
function PortfolioDAO() {
editService = new
HTTPService(); // maybe this
constructor needs arguments?
editService.serviceName="portfolio"; //
this is set up in
flex-config.xml and works when using mx:HTTPService
editService.method="POST"
editService.contentType="application/xml"
editService.showBusyCursor=true;
editService.xmlEncode=encodeSaveRequest; // this
is defined
in the class and I can verify that it does get
called and returns the
correct result
editService.addEventListener("result",
handleResult); //
these are defined in the class
editService.addEventListener("fault", handleFault);
}
public function
moveEntry(entry:PortfolioEntryModel,
newPortfolioName:String):Void {
entry.portfolioName = newPortfolioName;
editService.request = entry; // this causes
encodeSaveRequest to be called properly
editService.send(); // nothing gets sent, and then the fault
event gets thrown
}
...
}
Any ideas? Thanks
- rdo