Hi,
I am developed the web service class for accessing the webservice and webservice input as array values and this webservice class return the xml values to the call back function and based on the response we can proceed
package service
{
import mx.managers.CursorManager;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.soap.LoadEvent;
import mx.rpc.soap.WebService;
public class URLWebService
{
private var _argValues:Array;
private var _serviceURL:String = "";
private var _operationName:String = "";
private var _callbackObject:Object;
private var _callbackFun:Function;
private var webService:WebService;
private var _showBusyCursor:Boolean = false;
private var _isArguments:Boolean = false;
private var _serviceError:MessageServices = new MessageServices("Service Load Problem","Warning");
private var _webServiceURLError:MessageServices = new MessageServices("Webservice URL Error","Warning");
public function get serviceURL():String
{
return _serviceURL;
}
public function set serviceURL(val:String):void
{
if(_serviceURL != val)
_serviceURL = val;
}
public function get operationName():String
{
return _operationName;
}
public function set operationName(val:String):void
{
if(_operationName != val)
_operationName = val;
}
public function get showBusyCursor():Boolean
{
return _showBusyCursor;
}
public function set showBusyCursor(val:Boolean):void
{
if(_showBusyCursor != val)
_showBusyCursor = val;
}
public function get argValues():Array
{
return _argValues;
}
public function set argValues(val:Array):void
{
if(_argValues != val)
_argValues = val;
}
public function get callbackObject():Object
{
return _callbackObject;
}
public function set callbackObject(val:Object):void
{
if(_callbackObject != val)
_callbackObject = val;
}
public function get callbackFun():Function
{
return _callbackFun;
}
public function set callbackFun(val:Function):void
{
if(_callbackFun != val)
_callbackFun = val;
}
public function get serviceError():MessageServices
{
return _serviceError;
}
public function set serviceError(val:MessageServices):void
{
if(_serviceError != val)
_serviceError = val;
}
public function get webServiceURLError():MessageServices
{
return _webServiceURLError;
}
public function set webServiceURLError(val:MessageServices):void
{
if(_webServiceURLError != val)
_webServiceURLError = val;
}
public function URLWebService()
{
}
public function load(argVal:Array=null,callbackObject:Object=null,callbackFunction:Function=null):void
{
if(_serviceURL && _serviceURL != "")
{
if(argVal)
{
_argValues = argVal;
_isArguments = true;
}
if(_showBusyCursor)
{
CursorManager.setBusyCursor();
}
webService = new WebService();
webService.wsdl = _serviceURL;
webService[_operationName].resultFormat = "e4x";
webService[_operationName].addEventListener(ResultEvent.RESULT,onResult);
webService[_operationName].addEventListener(FaultEvent.FAULT,onFault);
webService.addEventListener(LoadEvent.LOAD,onLoad);
webService.loadWSDL();
_callbackObject = callbackObject;
_callbackFun = callbackFunction;
}
else
_webServiceURLError.show();
}
private function onResult(evt:ResultEvent):void
{
if(_callbackObject && _callbackFun != null)
{
var xml:XML = new XML(evt.result);
var ResultXML:XML;
try
{
ResultXML = XML(xml.*.*);
if(_showBusyCursor)
CursorManager.removeBusyCursor();
}
catch(e:Error)
{
ResultXML = new XML("Sucessfully Added ");
}
_callbackFun.call(_callbackObject,ResultXML);
}
else
_serviceError.show();
webService[_operationName].removeEventListener(ResultEvent.RESULT,onResult);
}
private function onFault(evt:FaultEvent):void
{
_serviceError.show();
webService[_operationName].removeEventListener(FaultEvent.FAULT,onFault);
}
private function onLoad(evt:LoadEvent):void
{
if(_isArguments)
{
_isArguments = false;
var input:Object = new Object();
for(var i:int=0;i<_argValues.length;i++)
{
input[_argValues[i].name] = _argValues[i].value;
}
webService[_operationName].arguments = input;
}
webService[_operationName].send();
webService.removeEventListener(LoadEvent.LOAD,onLoad);
}
}}
I am developed the web service class for accessing the webservice and webservice input as array values and this webservice class return the xml values to the call back function and based on the response we can proceed
package service
{
import mx.managers.CursorManager;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.soap.LoadEvent;
import mx.rpc.soap.WebService;
public class URLWebService
{
private var _argValues:Array;
private var _serviceURL:String = "";
private var _operationName:String = "";
private var _callbackObject:Object;
private var _callbackFun:Function;
private var webService:WebService;
private var _showBusyCursor:Boolean = false;
private var _isArguments:Boolean = false;
private var _serviceError:MessageServices = new MessageServices("Service Load Problem","Warning");
private var _webServiceURLError:MessageServices = new MessageServices("Webservice URL Error","Warning");
public function get serviceURL():String
{
return _serviceURL;
}
public function set serviceURL(val:String):void
{
if(_serviceURL != val)
_serviceURL = val;
}
public function get operationName():String
{
return _operationName;
}
public function set operationName(val:String):void
{
if(_operationName != val)
_operationName = val;
}
public function get showBusyCursor():Boolean
{
return _showBusyCursor;
}
public function set showBusyCursor(val:Boolean):void
{
if(_showBusyCursor != val)
_showBusyCursor = val;
}
public function get argValues():Array
{
return _argValues;
}
public function set argValues(val:Array):void
{
if(_argValues != val)
_argValues = val;
}
public function get callbackObject():Object
{
return _callbackObject;
}
public function set callbackObject(val:Object):void
{
if(_callbackObject != val)
_callbackObject = val;
}
public function get callbackFun():Function
{
return _callbackFun;
}
public function set callbackFun(val:Function):void
{
if(_callbackFun != val)
_callbackFun = val;
}
public function get serviceError():MessageServices
{
return _serviceError;
}
public function set serviceError(val:MessageServices):void
{
if(_serviceError != val)
_serviceError = val;
}
public function get webServiceURLError():MessageServices
{
return _webServiceURLError;
}
public function set webServiceURLError(val:MessageServices):void
{
if(_webServiceURLError != val)
_webServiceURLError = val;
}
public function URLWebService()
{
}
public function load(argVal:Array=null,callbackObject:Object=null,callbackFunction:Function=null):void
{
if(_serviceURL && _serviceURL != "")
{
if(argVal)
{
_argValues = argVal;
_isArguments = true;
}
if(_showBusyCursor)
{
CursorManager.setBusyCursor();
}
webService = new WebService();
webService.wsdl = _serviceURL;
webService[_operationName].resultFormat = "e4x";
webService[_operationName].addEventListener(ResultEvent.RESULT,onResult);
webService[_operationName].addEventListener(FaultEvent.FAULT,onFault);
webService.addEventListener(LoadEvent.LOAD,onLoad);
webService.loadWSDL();
_callbackObject = callbackObject;
_callbackFun = callbackFunction;
}
else
_webServiceURLError.show();
}
private function onResult(evt:ResultEvent):void
{
if(_callbackObject && _callbackFun != null)
{
var xml:XML = new XML(evt.result);
var ResultXML:XML;
try
{
ResultXML = XML(xml.*.*);
if(_showBusyCursor)
CursorManager.removeBusyCursor();
}
catch(e:Error)
{
ResultXML = new XML("
}
_callbackFun.call(_callbackObject,ResultXML);
}
else
_serviceError.show();
webService[_operationName].removeEventListener(ResultEvent.RESULT,onResult);
}
private function onFault(evt:FaultEvent):void
{
_serviceError.show();
webService[_operationName].removeEventListener(FaultEvent.FAULT,onFault);
}
private function onLoad(evt:LoadEvent):void
{
if(_isArguments)
{
_isArguments = false;
var input:Object = new Object();
for(var i:int=0;i<_argValues.length;i++)
{
input[_argValues[i].name] = _argValues[i].value;
}
webService[_operationName].arguments = input;
}
webService[_operationName].send();
webService.removeEventListener(LoadEvent.LOAD,onLoad);
}
}}
No comments:
Post a Comment