This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Flex and the fly likes Any APIs in Flex for figuring out server details at runtime ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Flex
Bookmark "Any APIs in Flex for figuring out server details at runtime ?" Watch "Any APIs in Flex for figuring out server details at runtime ?" New topic
Author

Any APIs in Flex for figuring out server details at runtime ?

Rajat Sharmanaive
Ranch Hand

Joined: Jun 30, 2011
Posts: 41

Hi

I have a flex application using BlazeDS for connectivity with java. As those who have used it would know, BlazeDS requires me to sort of hardcode the endpoint url for any given channel in the services-config.xml. This services-config.xml is also given as a compiler argument to flex application.
for e.g.

Channels like these are then used by remote objects for invoking back end java methods. Here, though {server.name} and {server.port} are loaded at run time, {context.root} is loaded at compile time. Moreover at times, there may be no {server.port} in prod environment. My requirement is to find some way by which the application can dynamically create the channel for any remote object. To further elaborate, I need to do these two steps:
1) to figure out the server where the swf is installed at run time and obtain details like protocol, server:port etc.
2) to create a channel dynamically using the above details.
Now I have an idea about the second step - How to create a channel and assign it to a remote object. This is what I think can be done:


With this approach, services.config.xml is as good as absent. Because as far as the channel aspect of it is concerned, we are setting the details at runtime. I cannot find any APIs in flex that will help me give the details of the server where the swf is installed. Something like this.getServer() etc. I know this might seem a strange requirement to some but that is what I have to do. My hint (a hint also means that this is "exaclty" how the boss wants it to be done- no other way !) is to find the APIs in flex that I just mentioned
Please give any suggestions if anyone has any knowledge about this.


Rajat Sharma
Rajat Sharmanaive
Ranch Hand

Joined: Jun 30, 2011
Posts: 41

Solution obtained.
Get the url via Application.application.url and use URLutils that has various static utility methods to obtain different tokens of the obtained url. These tokens can then be used to construct server url.
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Any APIs in Flex for figuring out server details at runtime ?
 
Similar Threads
DataGrid With RemoteObject
Error when using flex+seam+flamingo
Transfer File using Remote Object
BlazeDS is not responding through Apache
Need some explanation on a configuration fix I made