Hi,
I have been trying to parse a response for my android application.
The current situation is, I have tried to login to a sfs server which sends me an extension response shown as following:
<msg t='xt'><body action='xtRes' r='-1'><![CDATA[<dataObj><var n='id' t='s'>3</var><var n='ei' t='n'>111</var><var n='_cmd' t='s'>logOK</var><var n='zone' t='s'>Trial Zone</var></dataObj>]]></body></msg>
OR
<msg t='xt'><body action='xtRes' r='-1'><![CDATA[<dataObj><var n='id' t='s'>3</var><var n='ei' t='n'>111</var><var n='_cmd' t='s'>logKO</var><var n='zone' t='s'>Trial Zone</var></dataObj>]]></body></msg>
I have been using the following code to extract whether the response has "logOK" or "logKO". But I am getting null pointer exception in the line "String cmd = event.getParams().get("_cmd").toString();"
And when I am trying to print using:
System.out.println(event.getParams().get("dataObj"));
I am getting the following this in logcat:
{ "id" : "3", "ei" : "111" , "_cmd" : "logOK" , "zone" : "Trail Zone" }
or
{ "id" : "3", "ei" : "111" , "_cmd" : "logKO" , "zone" : "Trail Zone" }
The code I am using is given below. Requesting for your help to clear this issue.
Thanks,
Ankur
\\The code to handle extension response event
public void handleEvent(final SFSEvent event) {
runOnUiThread(new Runnable() { public void run() {
if(event.getName().equals(SFSEvent.onExtensionResponse))
{
System.out.println("EXTENSION MESSAGE RECEIVED");
SFSObject data = event.getParams();
System.out.println(event.getParams().get("dataObj"));
String cmd = event.getParams().get("n").toString();
if(cmd.equals("logKO"))
{
showDialog(DIALOG_LOGIN_ERROR_ID);
}
else if (cmd.equals("logOK"))
{
showDialog(DIALOG_LOGIN_SUCCESS_ID);
}
}
}
});
}
Unable to parse response on SFSEvent.onExtensionResponse
-
- Posts: 1
- Joined: 30 Nov 2010, 09:31
- Location: Gurgaon India
- Contact:
Unable to parse response on SFSEvent.onExtensionResponse
--
Ankur Prasad
Ankur Prasad
Return to “Java2SE / Android Client API”
Who is online
Users browsing this forum: No registered users and 8 guests