Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Set properties
- public var baseURL:String = new String();
- private var sessionID:String;
- /******************************************
- *
- * Method for processing HTTP Requests
- * to the docSTAR server.
- *
- * ***************************************/
- private function processRequest(targetURL:String, targetMethod:String,
- successListner:Function, failListner:Function = null):void
- {
- //Create a new HTTP service to connect to the docSTAR server.
- var currentHS:mx.rpc.http.HTTPService= new mx.rpc.http.mxml.HTTPService;
- //Set the properties of the service
- currentHS.url = targetURL;
- currentHS.method = targetMethod;
- //Set the cursor to busy
- cursorManager.setBusyCursor();
- //Send the service and then listen for completion
- currentHS.send();
- currentHS.addEventListener("result", successListner);
- //If a failListner was passed attach it to the http service
- //If one was not passed, ignor this.
- if(failListner != null)
- currentHS.addEventListener("fault", failListner);
- }
- /******************************************
- *
- * Method for general HTTP Request
- * failures.
- *
- * ***************************************/
- private function generalHTTPFailure():void
- {
- //A general error message to the user.
- Alert.show("There was an error in your request");
- }
- /******************************************
- *
- * Method for retrieving a session ID.
- * A session ID is used by almost all
- * other methods.
- *
- * ***************************************/
- private function retrieveSessionID():void
- {
- //Create and generate a string containing
- //a url of the location of the docSTAR server's
- //REST endpoint for connecting.
- var targetURL:String = baseURL + 'systemservice.svc/rest/connect';
- //Call the process request method and pass it the target URl and function cointaining
- //instructions on what to do with the resulting XML from docSTAR
- processRequest(targetURL,"GET",function(passedEvent:ResultEvent):void
- {
- //Process the returned XML file and set the seesionID accordingly
- sessionID = passedEvent.result.ConnectResponse.ConnectResult;
- sessionIDLB.text = sessionID;
- //Set cursor back to normal
- cursorManager.removeBusyCursor();
- },generalHTTPFailure);
- }
Add Comment
Please, Sign In to add comment