Which version of Cairngorm are you using? seems like an old one. At quick
glance your code seems fine.
Not really sure what to recommend except maybe upgrade to version 2.2.1? You
dont have to do that call to loadWSDL(), it is taken of for you.
Here is that the delegate should look like:
public class AgentDelegate {
private var service:Object;
private var responder:IResponder;
public function AgentDelegate( responder:IResponder ) {
service = ServiceLocator.getInstance().getWebService( "agentServices" );
this.responder = responder;
}
public function search( criteria:String ):void {
var call:AsyncToken = service.search( criteria );
call.addResponder( responder );
}
}
And here is the Command class:
public class SearchAgentCmd implements ICommand, IResponder {
public function SearchAgentCmd() {
}
public function execute( event:CairngormEvent ):void {
var evt:SearchAgentEvent = event as SearchAgentEvent;
var delegate:AgentDelegate = new AgentDelegate( this );
delegate.search( evt.name );
}
public function result( event:Object ):void {
var evt:ResultEvent = event as ResultEvent;
UserModel.getInstance().agentSearchResults = evt.result as ArrayCollection;
}
public function fault( event:Object ):void {
var evt:FaultEvent = event as FaultEvent;
//show error message somehow
}
}
Dimitrios Gianninas
RIA Developer and Team Lead
Optimal Payments Inc.
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of jfournet
Sent: Thursday, July 03, 2008 6:04 PM
To: [email protected]
Subject: [flexcoders] Cairngorm Result and Fault Handlers not called
I have one command in my application in which the result and fault
handlers are not called. All other work fine. The webservice that
is tied to it gets executed and data is returned, as I can see it in
the flex log file. Does anyone know what might cause this???
Command File:
package com.bmc.rem.command.learning
{
import com.adobe.cairngorm.business.Responder;
import com.adobe.cairngorm.commands.Command;
import com.adobe.cairngorm.control.CairngormEvent;
import com.bmc.rem.common.eventBroadcaster.REMEventBroadcaster;
import com.bmc.rem.controller.REMControl;
import com.bmc.rem.delegate.probe.ProbeServicesDelegate;
import com.bmc.rem.vo.learning.*;
import mx.utils.ObjectUtil;
import mx.collections.ArrayCollection;
public class GetLearningResultsCommand implements Command, Responder
{
public function execute( event:CairngormEvent ) : void
{
trace("******* executing get learning results *******");
var delegate: ProbeServicesDelegate = new
ProbeServicesDelegate( this );
delegate.getLearningResults(event.data);
trace("****** after delegate.getLearningResults *****");
}
/**
* The onResult method is called when the server side method
completes successfully.
* @param event The event containing the information returned by
the server.
*
*/
public function onResult( event : *=null ) : void
{
trace("*******************learning data format =
**************" + ObjectUtil.toString(event.result));
REMEventBroadcaster.getInstance().dispatchEvent
(REMControl.EVENT_GET_LEARNING_RESULTS_SUCCESSFUL, null);
}
/**
* The onFault method is called when the server side method call
returns an exception.
* @param event The event containing the exception returned by the
server.
*
*/
public function onFault( event : *=null ) : void
{
trace("****** on fault learning restults");
REMEventBroadcaster.getInstance().dispatchEvent
(REMControl.EVENT_SHOW_SERVER_ERROR, event.fault.message);
REMEventBroadcaster.getInstance().dispatchEvent(
REMControl.EVENT_GET_LEARNING_RESULTS_FAILURE );
}
}
}
Delegate:
package com.bmc.rem.delegate.probe
{
import com.adobe.cairngorm.business.Responder;
import com.adobe.cairngorm.business.ServiceLocator;
import com.bmc.rem.model.ModelLocator;
import com.bmc.rem.vo.probe.LearningCriteriaVO;
import mx.rpc.AsyncToken;
import mx.rpc.soap.mxml.WebService;
public class ProbeServicesDelegate
{
/**
* The responder to the server side service calls
*/
private var responder:Responder;
private var service:Object;
private var probeServicesFacade:Object;
public function ProbeServicesDelegate( responder : Responder )
{
this.probeServicesFacade = ServiceLocator.getInstance
().getService("probeServicesFacade") as WebService;
if( !ModelLocator.getInstance().isProbeWSDLLoaded)
{
ModelLocator.getInstance().isProbeWSDLLoaded =
true;
this.probeServicesFacade.loadWSDL();
}
this.responder = responder;
}
public function startLearning
(learningSession:LearningCriteriaVO):void
{
var startLearningString:String =
"<q1:SetLearningSetting
xmlns:q0=\"http://tmremprobe.bmc.com/datamodel/common
<http://tmremprobe.bmc.com/datamodel/common> \"
xmlns:q1=\"http://tmremprobe.bmc.com/ws/ProbeService
<http://tmremprobe.bmc.com/ws/ProbeService> \">" +
"<q0:Learning>Active</q0:
Learning>" +
"<q0:UserId />" +
"<q0:IPRange>" +
"<q0:StartingIP>" +
learningSession.fromIpAddress +
"</q0:StartingIP>" +
"<q0:EndingIP>" +
learningSession.toIpAddress +
"</q0:EndingIP>"
+
"</q0:IPRange>" +
"<q0:URLPattern>" +
learningSession.urlPatternFilter +
"</q0:URLPattern>" +
"<q0:CapturePeriod>" +
learningSession.learningDuration +
"</q0:CapturePeriod>" +
"<q0:ResultLimit>" +
learningSession.learningCount +
"</q0:ResultLimit>" +
"</q1:SetLearningSetting>
";
trace("startLearningString = " +
startLearningString);
var startLearningXML:XML = new XML
(startLearningString);
trace("startLearningXML = " + startLearningXML);
var endpointURI:String = "http://" +
learningSession.probe.probeHost + ":" +
learningSession.probe.probeConnectionPort
+ "/axis2/services/ProbeService/SetLearningSetting";
this.probeServicesFacade.endpointURI =
endpointURI;
trace("endpointURI " + endpointURI);
var call:AsyncToken =
probeServicesFacade.SetLearningSetting(startLearningXML);
trace("after invoking webservice");
call.resultHandler = responder.onResult;
call.faultHandler = responder.onFault;
}
public function stopLearning
(learningSession:LearningCriteriaVO):void
{
var stopLearningString:String =
"<q1:SetLearningSetting
xmlns:q0=\"http://tmremprobe.bmc.com/datamodel/common
<http://tmremprobe.bmc.com/datamodel/common> \"
xmlns:q1=\"http://tmremprobe.bmc.com/ws/ProbeService
<http://tmremprobe.bmc.com/ws/ProbeService> \">" +
"<q0:Learning>Inactive</q
0:Learning>" +
"<q0:UserId />" +
"<q0:IPRange>" +
"<q0:StartingIP>" +
learningSession.fromIpAddress +
"</q0:StartingIP>" +
"<q0:EndingIP>" +
learningSession.toIpAddress +
"</q0:EndingIP>"
+
"</q0:IPRange>" +
"<q0:URLPattern>" +
learningSession.urlPatternFilter +
"</q0:URLPattern>" +
"<q0:CapturePeriod>" +
learningSession.learningDuration +
"</q0:CapturePeriod>" +
"<q0:ResultLimit>" +
learningSession.learningCount +
"</q0:ResultLimit>" +
"</q1:SetLearningSetting>
";
var endpointURI:String = "http://" +
learningSession.probe.probeHost + ":" +
learningSession.probe.probeConnectionPort
+ "/axis2/services/ProbeService/SetLearningSetting";
this.probeServicesFacade.endpointURI =
endpointURI;
var stopLearningXML:XML = new XML
(stopLearningString);
trace("stopLearningXML = " + stopLearningXML);
var call:AsyncToken =
probeServicesFacade.SetLearningSetting(stopLearningXML);
call.resultHandler = responder.onResult;
call.faultHandler = responder.onFault;
}
public function getLearningResults
(learningCriteria:LearningCriteriaVO):void
{
var getLearningResultsString:String
= "<q0:GetLearningResult " +
"xmlns:q0=\"http://
tmremprobe.bmc.com/ws/ProbeService\"/>";
/*"<soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> \" " +
"xmlns:q0=\"http://tmremp
robe.bmc.com/datamodel/common\"
xmlns:q1=\"http://tmremprobe.bmc.com/ws/ProbeService
<http://tmremprobe.bmc.com/ws/ProbeService> \" " +
"xmlns:xsd=\"http://www.w
3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-
<http://www.w3.org/2001/XMLSchema->
instance\">" +
"<soapenv:Body>"
+
"<q0:GetLearningResult "
+
"xmlns:q0=\"http://tmremp
robe.bmc.com/datamodel/common\">" +
"</q0:GetLearningResult>"
+
"</soapenv:Body>" +
"</soapenv:Envelope>";*/
var endpointURI:String = "http://" +
learningCriteria.probe.probeHost + ":" +
learningCriteria.probe.probeConnectionPort
+ "/axis2/services/ProbeService/GetLearningResult";
this.probeServicesFacade.endpointURI =
endpointURI;
trace("getLearningResultsSTring = " +
getLearningResultsString);
var getLearningResultsXML:XML = new XML
(getLearningResultsString);
trace("getLearningResultsXML = " +
getLearningResultsXML);
var call:AsyncToken =
probeServicesFacade.GetLearningResult(getLearningResultsXML);
call.resultHandler = responder.onResult;
call.faultHandler = responder.onFault;
trace("after get learning results");
}
}
}
--
WARNING
-------
This electronic message and its attachments may contain confidential,
proprietary or legally privileged information, which is solely for the use of
the intended recipient. No privilege or other rights are waived by any
unintended transmission or unauthorized retransmission of this message. If you
are not the intended recipient of this message, or if you have received it in
error, you should immediately stop reading this message and delete it and all
attachments from your system. The reading, distribution, copying or other use
of this message or its attachments by unintended recipients is unauthorized and
may be unlawful. If you have received this e-mail in error, please notify the
sender.
AVIS IMPORTANT
--------------
Ce message électronique et ses pièces jointes peuvent contenir des
renseignements confidentiels, exclusifs ou légalement privilégiés destinés au
seul usage du destinataire visé. L'expéditeur original ne renonce à aucun
privilège ou à aucun autre droit si le présent message a été transmis
involontairement ou s'il est retransmis sans son autorisation. Si vous n'êtes
pas le destinataire visé du présent message ou si vous l'avez reçu par erreur,
veuillez cesser immédiatement de le lire et le supprimer, ainsi que toutes ses
pièces jointes, de votre système. La lecture, la distribution, la copie ou
tout autre usage du présent message ou de ses pièces jointes par des personnes
autres que le destinataire visé ne sont pas autorisés et pourraient être
illégaux. Si vous avez reçu ce courrier électronique par erreur, veuillez en
aviser l'expéditeur.