Joel_Sisko
asked on
Using Flex to graphically display data from url request...
Dear Experts:
I am new to programming and as well as Flex/AIR from Adobe. I am trying to build an application that will send a url request to a server and then take the information returned from the request and display that information visually.
The server we are using requires first for us to login, the url to do that is:
http://192.168.170.128:7878/command=Login&username=admin&secret=1234
The response to that request is as such:
<ajax-response>
<response type="object" id="unknown">
<generic response="Success" message="Authentication accepted"/>
</response>
</ajax-response>
Then I want to execute the command that will return the system users, the url for that is:
http://192.168.170.128:7878/command=listusers
The response to that is as such:
<ajax-response>
<response type="object" id="unknown">
<generic response="Success" message="User list will follow"/>
</response>
<response type="object" id="unknown">
<generic event="userEntry" Usertype="Private" Username="John" Location="NJ" status="Active"/>
</response>
<response type="object" id="unknown">
<generic event="userEntry" Usertype="Private" Username="Tim" Location="CA" status="Active"/>
</response>
<response type="object" id="unknown">
<generic event="userEntry" Usertype="Public" Username="Bob" Location="VA" status="Active"/>
</response>
<generic event="UserlistComplete" TotalUsers="3"/>
</response>
</ajax-response>
So I would like to do is this:
Have a basic AIR application that has a button that when pressed will login in the user and will return the user information showing an image for each user based on user type (Public or Private), then provide a label under that image that shows the username and location.
I hope this is enough information in advance.
Thanks,
Joel
I am new to programming and as well as Flex/AIR from Adobe. I am trying to build an application that will send a url request to a server and then take the information returned from the request and display that information visually.
The server we are using requires first for us to login, the url to do that is:
http://192.168.170.128:7878/command=Login&username=admin&secret=1234
The response to that request is as such:
<ajax-response>
<response type="object" id="unknown">
<generic response="Success" message="Authentication accepted"/>
</response>
</ajax-response>
Then I want to execute the command that will return the system users, the url for that is:
http://192.168.170.128:7878/command=listusers
The response to that is as such:
<ajax-response>
<response type="object" id="unknown">
<generic response="Success" message="User list will follow"/>
</response>
<response type="object" id="unknown">
<generic event="userEntry" Usertype="Private" Username="John" Location="NJ" status="Active"/>
</response>
<response type="object" id="unknown">
<generic event="userEntry" Usertype="Private" Username="Tim" Location="CA" status="Active"/>
</response>
<response type="object" id="unknown">
<generic event="userEntry" Usertype="Public" Username="Bob" Location="VA" status="Active"/>
</response>
<generic event="UserlistComplete" TotalUsers="3"/>
</response>
</ajax-response>
So I would like to do is this:
Have a basic AIR application that has a button that when pressed will login in the user and will return the user information showing an image for each user based on user type (Public or Private), then provide a label under that image that shows the username and location.
I hope this is enough information in advance.
Thanks,
Joel
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
evcr,
Thanks for the response. It was not working at first, so I used wireshark to capture the login from a regualr browser that works. I noticed that user FireFox is was using GET verses POST, so I changed that and now I can see on the server the request to autneticate.
The information being sent should be:
action=Login&username=admi n&secret=1 234
But I am getting this:
action=Login&secret=1234&u sername=ad min
I tried switching the lines in the "goLogin()" hoping the order would rectify, but still the same result.
Joel
Thanks for the response. It was not working at first, so I used wireshark to capture the login from a regualr browser that works. I noticed that user FireFox is was using GET verses POST, so I changed that and now I can see on the server the request to autneticate.
The information being sent should be:
action=Login&username=admi
But I am getting this:
action=Login&secret=1234&u
I tried switching the lines in the "goLogin()" hoping the order would rectify, but still the same result.
Joel
is this on a https service?
if so you should be using 'https..' etc. in the url.
Also you may need a crossdomain.xml file to allow the ip ports to converse.
e.g. try this crossdomain.xml file:
<?xml version="1.0" encoding="iso-8859-1"?>
<cross-domain-policy>
<allow-access-from domain="*" ports="80,443" secure="false" />
</cross-domain-policy>
If it works then adjust your secruity in this file respectively;
if so you should be using 'https..' etc. in the url.
Also you may need a crossdomain.xml file to allow the ip ports to converse.
e.g. try this crossdomain.xml file:
<?xml version="1.0" encoding="iso-8859-1"?>
<cross-domain-policy>
<allow-access-from domain="*" ports="80,443" secure="false" />
</cross-domain-policy>
If it works then adjust your secruity in this file respectively;
ASKER
evcr,
No this is on http, but I found the problem just not the solution:
httpVars.action = 'Login';
httpVars.usernam = 'admin;
httpVars.secret = '1234';
httpSvc.send(httpVars);
When the request is sent, it is putting the variables in alphabetical order, command+secret+username, where I need the order to be command+username+secret.
I confirmed this by using Zsecret instead of secret and the order was right just Zsecret will not do anything.
Joel
No this is on http, but I found the problem just not the solution:
httpVars.action = 'Login';
httpVars.usernam = 'admin;
httpVars.secret = '1234';
httpSvc.send(httpVars);
When the request is sent, it is putting the variables in alphabetical order, command+secret+username, where I need the order to be command+username+secret.
I confirmed this by using Zsecret instead of secret and the order was right just Zsecret will not do anything.
Joel
ASKER
evcr,
I have the same result using <mx:request>, that is the values are being alphabetically sorted.
Joel
I have the same result using <mx:request>, that is the values are being alphabetically sorted.
Joel
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
private function goLogin():void {
httpSvc.send();
}
]]>
</mx:Script>
<mx:HTTPService resultFormat="e4x" id="httpSvc" url="http://192.168.170.128:8088/server/commands" showBusyCursor="true" useProxy="false" method="GET">
<mx:request xmlns="">
<zcommand>Login</zcommand>
<ausername>admin</ausername>
<password>1234</password>
</mx:request>
</mx:HTTPService>
<mx:Button x="99" y="155" label="login" click="goLogin();"/>
</mx:WindowedApplication>
Yes I noticed that, normally it would not matter what order they were in but I guess the web service in your case isn't that sort of beast. Having said that I think it unnecessary that Flex is ordering them.
As I don't have access to your web service it's difficult to test. Could you try constructing a URLRequest from the variables and see if that works.
See code below...
//untested!
private function goLogin():void {
var requestString:String = 'http://192.168.170.128:7878/command=Login&username='+username.text+'&secret='+secret.text;
var request:URLRequest = new URLRequest(requestString);
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, httpResult);
loader.load(request);
}
private function httpResult(event:Event):void {
var httpSvc:XML = XML(event.target.data);
trace(httpSvc.toXMLString());
//If the trace is good here you can use my previous code to query the xml data
}
ASKER
evcr,
Bonehead move on my part, kept looking at captured packets verses if the connection actually worked with the server. Doh! It does in any order.
Thanks for sticking with me thorough this and all the help.
If you ever have a question on VoIP or phone systems in general follow my profile or head over to the VoIP section of EE.
Joel
Bonehead move on my part, kept looking at captured packets verses if the connection actually worked with the server. Doh! It does in any order.
Thanks for sticking with me thorough this and all the help.
If you ever have a question on VoIP or phone systems in general follow my profile or head over to the VoIP section of EE.
Joel
No prob. Cheers!
Open in new window