Hi,
achegedus wrote:
> I'm having a hard time learning Cairngorm, but I'm determined to
> figure it out!! My current problem is with my HTTPService. In my
> Delegate, I'm calling the service like this:
>
> public class ContactListDelegate
> {
> private var responder : IResponder;
> private var service : Object;
>
> public function ContactListDelegate(responder:IResponder)
> {
> this.service =
> ServiceLocator.getInstance().getHTTPService("ListContactsHS") as
> HTTPService;
> this.responder = responder
> }
>
> public function list():void
> {
> var token : AsyncToken = service.list();
> token.resultHandler = responder.result;
> token.faultHandler = responder.fault;
> }
>
> public function listResult():void
> {
> responder.result(responder);
> }
> }
>
> and then in my services.mxml i have this:
>
> <mx:HTTPService id="ListContactsHS"
> url="http://localhost:3004/webservice/list"
> useProxy="false"
> method="GET"
> makeObjectsBindable="false"
> result="event.token.resultHandler(event)"
> fault="event.token.resultHandler(event)" />
>
> (the service is written in Rails and on the local machine)
>
> When I call the event to get the data from service though, I get this
> error:
>
> Error: C0008E: HTTPService not found for ListContactsHS
> at com.adobe.cairngorm.business::HTTPServices/getService()
> at com.adobe.cairngorm.business::ServiceLocator/getHTTPService()
> at com.adamhegedus.contactmanager.business::ContactListDelegate$iinit()
The error seems to indicate the service cannot be found..
Is your Services.mxml in the same package as the Delegate?
Your Services.mxml is a ServiceLocator isnt it?
What does the top 4 or 5 lines of your service.mxml look like?
I dont think it really matters at this point as your service is not
found(so its not actually executing from the looks of it) but FWIW, this
is how I would/do, do it:
<mx:HTTPService id="ListContactsHS"
url="http://localhost:3004/webservice/list"
useProxy="false"
resultFormat="array"
/>
public class ContactListDelegate
{
private var responder : IResponder;
private var service : Object;
public function ContactListDelegate(responder:IResponder)
{
this.service =
ServiceLocator.getInstance().getHTTPService("ListContactsHS")
this.responder = responder
}
public function list():void
{
this.service.send().addResponder(responder);
}
}
In my Command I would just call list();
Something like:
class MyCommand {
execute() {
x = new ContactListDelegate(this);
x.list();
}
result(){
// get the result here from the event object.
}
fault(){
//handle a fault.
}
//end class
}
HTH.
shaun