Sunday, November 19, 2006

Cairngorm & Webservice

Cairngorm is good, but here is something you have to watch out for if you are using webservices.
If you locate a webservice using 'ServiceLocator' you have to also call 'loadWsdl()' on the webservice before invoking an operation on it. Otherwise, you don't get any errors nor does the webservice call reach the server (obviously, no result either)

4 comments:

Unknown said...

Dear all,

I am new to flex programming. Right now I wanna use webservice & cairngorm object, but I can't make it works. Is any one can share the complete project of using cairngorm with Webservice.

Wait for your kind reply.

Sunny regards,

Kado

Unknown said...

Hi Vishnu ,

I'm new to Cairngorm and have been struggling to get my webservice to work. I've got a simple sample application that I believe is 90% there but I'm missing something not sure if it's the loadWsdl or not but it never calls the web service.

Think I can get you to peek at it?
srieger@psclistens.com
Thanks!

Filipino Monkey said...

What you need to to do to get a webservice to work in cairngorm.

In the business package you need to create a services.xml
<cairngorm:ServiceLocator
<mx:WebService wsdl="http://someserver/somewsdl" id="myWS" showBusyCursor="true" makeObjectsBindable="false" useProxy="false" />
</cairngorm:ServiceLocator>

Then your command needs to implement IResponder

login command example
public function execute(event:CairngormEvent):void
{
var deleg:LoginDelegate = new LoginDelegate(this);
var e:LoginEvent = event as LoginEvent;
deleg.DoLogin(e.vo,e.password);
}

public function result(data:Object):void
{
if(data.result)
{

mx.controls.Alert.show( "Login successfull","Message");
}
else
mx.controls.Alert.show( "Wrong password","User Error");
}

LoginDelegate

private var service:WebService
protected var responder : IResponder;
public function LoginDelegate(responder:IResponder)
{
this.service = ServiceLocator.getInstance().getWebService( "myWS" ) as WebService;
this.responder = responder;
}

public function DoLogin(staff:Staff_VO,password:String):void
{


var call : Object = service.doLogin(staff,password);
call.addResponder( responder );
}

Unknown said...


Your summaries are always top-notch. Thanks for keeping us apprised. I’m reading every word here.

flex tickets