The short answer is Yes you can use session variables instead or url
variables.  It depends on what scripting language you are using.  For
example, I use coldfusion and can pass url variables through FlashVars
by accessing the variables using URL.VARIABL_NAME.  I can easily replace
this syntax to use a session variable by setting the flashvars to
SESSION.VARIABLE_NAME.  In .NET with C# I think you access the session
variables by SESSION["VARIABLE_NAME"].

 

Does this help?

 

John

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of thegators_2002
Sent: Monday, March 05, 2007 6:32 PM
To: [email protected]
Subject: [flexcoders] Can I access HTTP session variables in Flex
without using Flashvars?

 

I am able to create a web service request in Flex, using parameters
sent to the html page via a query string which is then passed in using
flashvars. However, now I am being asked if I can do this without
having a query string for all to see with this information in plain
sight. The idea is to use session variables to store this info. It's
just a few items, like an account ID, user ID, a URL for the WSDL
file, and a couple others.

I am not familiar with web sessions or with how that info gets
accessed by Flex, I am more of a desktop developer. So I ask if this
is a sound strategy, or if there are other, better ways to do this? 
And if there are any good examples available? 

The app has users log in and get authenticated, and we want to pass
that info to the web service. As it is right now, not authenticating
the user request and passing a couple IDs and a URL in the query
string would allow anybody anywhere to access that web service at any
time. I need some way to secure it or at least drastically limit the
amount of time it would be valid.

Thank you for any assistance!

Here is my code as of right now:

private var accountID:String; 
private var systemUserID:String;
private var myWebServiceURL:String;

public var MyService:WebService = new mx.rpc.soap.WebService();

// This method runs on start-up. It pulls in Flashvars from the
parent HTML file, and starts up the web service.
public function initApp():void
{ 
accountID = Application.application.parameters.accountID;
systemUserID = Application.application.parameters.systemUserID; 
myWebServiceURL = Application.application.parameters.webServiceURL;

// Call the web service to get an RRM results doc
UseWebService( myWebServiceURL + "?WSDL");
}

// Create a web service and load the WSDL, using ActionScript
public function UseWebService( wsdl:String):void 
{
// Set the path to the WSDL
MyService.wsdl = wsdl; 

// Set listeners for the result and fault events of the specific web
service method 

MyService.GetRRMAnalysisResultsFromAccountIDStr.addEventListener("result
",
resultHandler);

MyService.GetRRMAnalysisResultsFromAccountIDStr.addEventListener("fault"
,
faultHandler); 

// Add a listener event for the web service load completion
MyService.addEventListener("load", loadHandler);

// Load the WSDL into the web service
MyService.loadWSDL();
}

// Once the WSDL is loaded into the web service, this handler will
run. Call the appropriate service and send credentials.
public function loadHandler(event:LoadEvent):void 
{
MyService.GetRRMAnalysisResultsFromAccountIDStr( accountID,
systemUserID);
}


// If there is a fault in setting up the web service, this will run. 
It informs the user there was a problem.
public function faultHandler(event:FaultEvent):void 
{
Alert.show("An error occurred while accessing the web service: " +
event.fault.faultString + ".\nPlease close this application.", "Error");
} 

// Event Handler: listens for the web service call to be completed 
private function resultHandler(event:ResultEvent):void 
{ 
// Create an XML doc and load it with the XML string returned from the
web service
var myXml:XML = new
XML(MyService.GetRRMAnalysisResultsFromAccountIDStr.lastResult);

// Copy the XML doc to the custom class which will handle extracting 
ResultSet.XmlResults( myXml);
}

 

Reply via email to