Parsing XML server responses

63 views
Skip to first unread message

YUY0x7

unread,
Aug 23, 2006, 10:44:02 PM8/23/06
to Google Web Toolkit
Hi, I'm trying to have my server respond to queries with XML text. I'm
having a little trouble. Strangely, everything works well in FF, but in
IE the data contains one extra character that prevents the xml to be
parsed.

The .php file that responds is:

<?php

require_once("config.php");

$request = Data::parse(Request::httpPost());

?>
<?xml version="1.0"?>
<fxlresponse>
<?php

$response = "";

if (User::login($request->get("name"), $request->get("password")))
{
$response .= '<error ' . "\n" .
' id="0" /> ' . "\n" .
'<login ' . "\n" .
' session="' . Session::id() . '" ' . "\n" .
' name="' . User::name() . '" ' . "\n" .
' fullname="' . User::fullName() . '" ' . "\n" .
' type="' . User::type() . '" />' . "\n";
}
else
{
$response .= '<error ' . "\n" .
'id="2" />' . "\n";
}

// Send the response
echo $response;

?>
</fxlresponse>


In Firefox, the response is (as printed into a Label):

<fxlresponse> <error id="0"> <login
session="bhs49f0j9hjc2c2nvilftn72j2" name="gfaraj" fullname="George
Faraj" type="1"> </login></error></fxlresponse>

In IE, the response is:

<?xml version="1.0" ?>
- <fxlresponse>
<error id="0" />
<login session="2og11qots5vo5ipojvhg9pa8h5" name="gfaraj"
fullname="George Faraj" type="1" />
</fxlresponse>


Which seems to me to be formatted to "view" this XML. How can I make
this work? Also, notice that '<?xml version="1.0" ?>' is missing from
the FF response.

If it helps, the request to the server is made through a FormPanel that
has the following options:

form.setEncoding(FormPanel.ENCODING_URLENCODED);
form.setMethod(FormPanel.METHOD_POST);

Any help is appreciated. Thanks a lot.

CarlosEd

unread,
Aug 24, 2006, 8:53:10 AM8/24/06
to Google Web Toolkit

Isn't that a PHP problem? Rather then a GWT problem?

YUY0x7

unread,
Aug 24, 2006, 10:35:22 AM8/24/06
to Google Web Toolkit
I have no idea... Why would it work with firefox and not IE, though? I
asked #php in EFnet and they told me that php sent the XML in raw
format.

Hasn't anyone attempted to send xml from php to GWT that can give me
some direction?

Marcos Araujo Sobrinho

unread,
Aug 24, 2006, 11:02:11 AM8/24/06
to Google-We...@googlegroups.com
Try to set the content-type header. IExplorer have some troubles with this.

<?php

header('Content-type: text/xml');
require_once("config.php");

...

Marcos

-----Mensagem original-----
De: Google-We...@googlegroups.com
[mailto:Google-We...@googlegroups.com]Em nome de YUY0x7
Enviada em: quarta-feira, 23 de agosto de 2006 23:44
Para: Google Web Toolkit
Assunto: Parsing XML server responses

YUY0x7

unread,
Aug 24, 2006, 11:09:20 AM8/24/06
to Google Web Toolkit
Yes, I had tried many kinds of Content-types but I still get the same
response...
I tried:

text/xml
application/xml
text/plain
text/plain; charset=utf-8

I have no idea what's going on.

YUY0x7

unread,
Aug 25, 2006, 9:06:21 AM8/25/06
to Google Web Toolkit
*bump*

YUY0x7

unread,
Aug 25, 2006, 9:39:18 AM8/25/06
to Google Web Toolkit
Would it have something to do with how the HTTPRequest class has been
implemented for IE6? It uses the ActiveXObject, maybe that's formatting
my XML?

class HTTPRequestImplIE6 extends HTTPRequestImpl {

protected native JavaScriptObject doCreateXmlHTTPRequest() /*-{
return new ActiveXObject("Msxml2.XMLHTTP");
}-*/;
}

Tim

unread,
Aug 25, 2006, 7:44:30 PM8/25/06
to Google Web Toolkit
Please post the exact content of the "view source" within IE and FF.
They won't have any formatting in it, and we can see if there are any
suprious characters that one is more forgiving of.

YUY0x7

unread,
Aug 26, 2006, 1:39:09 AM8/26/06
to Google Web Toolkit
Hmm, well the "View Source" will only give me the HTML I have in the
public directory. The dynamic data that I'm receiving and displaying on
a Label/alert is not accessible through there. Is there anything else I
can provide?

YUY0x7

unread,
Aug 27, 2006, 5:42:21 PM8/27/06
to Google Web Toolkit
*bump* sorry, but maybe someone fresh can look at it.

georgeuoa

unread,
Aug 28, 2006, 1:55:44 AM8/28/06
to Google Web Toolkit
The View Source Chart [1] plugin for Firefox is your friend, it shows
the _rendered_ html generated by GWT.

G.

[1] http://jennifermadden.com/

YUY0x7

unread,
Aug 30, 2006, 7:35:15 PM8/30/06
to Google Web Toolkit
Nice extension.. thanks.
Ok, an update on this problem. When I set the content-type to
"text/xml", in Firefox I get null as the responseText, while in IE I
just get the same thing I was getting before. It seems that if the
content-type is "text/xml", I can only use the responseXML property of
the XMLHTTPRequest javascript object.That's fine with me, but I need to
know how to pass that property to my Java code.

For example, instead of doing this (this is straight from
HTTPRequestImpl.java):

xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
delete xmlHttp.onreadystatechange;
var localHandler = handler;
var responseText = xmlHttp.responseText;
handler = null;
xmlHttp = null;

localHandler.@com.google.gwt.user.client.ResponseTextHandler::onCompletion(Ljava/lang/String;)(responseText);
}
};

I'd like to call my own handler, and pass the xmlHttp.responseXML
property. What type should my Java function accept as parameter?

Thanks.

Reply all
Reply to author
Forward
0 new messages