google-code-export / gwtupload

Automatically exported from code.google.com/p/gwtupload
Other
1 stars 0 forks source link

XML tags are missing when calling getServerResponse() in Internet Explorer #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Upload a file in Internet Explorer (6,7,8)
2. XML Response from the getServerResponse() method does not match the XML 
String sent from the executeAction() method
3.

What is the expected output? What do you see instead?
String being constructed in executeAction():
<response>
<fileField>GWTMU-08068299556062694</fileField>
<fileName>1280858123557_BL BB Map.xlsx</fileName>
<fileSize>17482</fileSize>
<fileType>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</fil
eType>
<fileIsValid>true</fileIsValid>
</response>

String being received from getServerResponse():
GWTMU-08068299556062694</FILEFIELD> <FILENAME>1280858123557_BL BB 
Map.xlsx</FILENAME> <FILESIZE>17482</FILESIZE> 
<FILETYPE>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</FIL
ETYPE> <FILEISVALID>true</FILEISVALID> </RESPONSE>

What version of the product are you using? On what operating system?
0.5.8, 0.6, 0.6.1

Please provide any additional information below.
This issue is was reproduced in all versions of IE, however was not reproduced 
in Firefox or Chrome.
See the attached file for code snippits

Original issue reported on code.google.com by umpire...@gmail.com on 3 Aug 2010 at 6:09

Attachments:

GoogleCodeExporter commented 9 years ago
IE and Firefox/Chrome are parsing the text/html response differently.  This 
seems to be due to the doPost method of UploadAction executing the 
renderHtmlResponse() method sending text/html instead of the text/xml or 
text/plain that I was expecting.  I resolved this by overriding the doPost 
method and removing the condition that called the renderHtmlResponse() method.

Original comment by umpire...@gmail.com on 5 Aug 2010 at 5:14

GoogleCodeExporter commented 9 years ago
It is weird, because sending text/xml didn't work in IE6 time ago. I have to 
take a look again.

Original comment by manuel.carrasco.m on 23 Aug 2010 at 1:47

GoogleCodeExporter commented 9 years ago
I checked the POST, everything seems fine when the xml is arriving. Looks like 
the javascript (either gwt or gwt-upload) is messing things up..

Original comment by clon...@gmail.com on 23 Aug 2010 at 1:51

GoogleCodeExporter commented 9 years ago
Yes, the issue is in client side, when the response comes, it is displayed in a 
hidden iframe, and the problem is in how GWT reads the content of the iframe, 
depending on the browser if the server response is text/xml then the content of 
the iframe document can not be read. When I was playing with this text/plain 
seemed to work with all browsers.

Original comment by manuel.carrasco.m on 23 Aug 2010 at 1:57

GoogleCodeExporter commented 9 years ago
Hi,

Same issue here.
I tried the fix mentionned in comment 1 but it didn't work.
Do you have another solution ?

Thanks,

Thomas

Original comment by thomas.frezel@gmail.com on 16 Sep 2010 at 1:52

GoogleCodeExporter commented 9 years ago
I have a workaround for this, in your client code add a native method to get 
the browser version:

public static native String getUserAgent() /*-{
    return navigator.userAgent.toLowerCase();
    }-*/;

Then add 
if(getUserAgent().contains("msie"))
                {
                    xml = "<RESPONSE><FILE-1-FIELD>" + xml;
                    xml = xml.toLowerCase();
                }
This is just a hack to get my app working in IE8, but it works.

The returned xml is capitialised in IE8. In IE7 only null is returned.
James

Original comment by james.gu...@googlemail.com on 1 Oct 2010 at 6:46

GoogleCodeExporter commented 9 years ago
that workaround will not work for us. We get

com.google.gwt.xml.client.impl.DOMParseException:
Failed to parse: GWTU-008588957556429666</FILE-1-FIELD> 
<FILE-1-NAME>b7KjjcEH6stBzxZW6JnPcA==</FILE-1-NAME> 
<FILE-1-SIZE>28521</FILE-1-SIZE> <FIL

in IE7 on uploading. Firefox works fine.

Original comment by per.ab...@gmail.com on 25 Nov 2010 at 1:12

GoogleCodeExporter commented 9 years ago
My work around:
I keep renderHtmlResponse with text/html ('text/plain'
cannot be made to work properly on all browsers)

[Server code] in my executeAction, I put my xml between html comment :

return "<html><head><title>results</title></head><body><!--<response>\n" + 
xmlResponse + "</response>\n--></body></html>";

[client code]

        // remove comment before parse xml
        private String extractXml(String serverResponse) {
            String result = serverResponse;
            int startIndex = result.indexOf("<!--") + 4;
            int endIndex = result.indexOf("-->") - 1;
            if (startIndex > -1 && endIndex > -1) {
                result = result.substring(startIndex, endIndex);
            }
            return result;
        }

        public void parseReponse(String serverResponse) {
            serverResponse = extractXml(serverResponse);
            // You can parse this information using XML or JSON libraries
            com.google.gwt.xml.client.Document doc = XMLParser
                    .parse(serverResponse);
            serverResponse = extractXml(serverResponse);
            // You can parse this information using XML or JSON libraries
            com.google.gwt.xml.client.Document doc = XMLParser
                    .parse(serverResponse);
            ...
        }

It's work with IE7 IE8 and FF3.6
It should be better to do somthing like his in Uplaoder class :

  private SubmitCompleteHandler onSubmitCompleteHandler = new SubmitCompleteHandler() {
    public void onSubmitComplete(SubmitCompleteEvent event) {
      String result = event.getResults();
      int startIndex = result.indexOf("<!--")+4;
      int endIndex = result.indexOf("-->")-1;
      if(startIndex>-1 && endIndex>-1) {
          result = result.substring(startIndex,endIndex);
      }
      serverResponse = result;     
      log("onSubmitComplete: " + serverResponse, null);
    }
  };

I found this solution when I read this thread:
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/cae1d9922
2fec795/8b94b2a26a911682?show_docid=8b94b2a26a911682

Original comment by b.mouch...@gmail.com on 3 Dec 2010 at 3:33

GoogleCodeExporter commented 9 years ago
Hello, latest snapshot has a workaround for this, could you test if it works 
for you

thanks.
- Manolo

Original comment by manuel.carrasco.m on 29 Dec 2010 at 10:35

GoogleCodeExporter commented 9 years ago

Original comment by manuel.carrasco.m on 29 Dec 2010 at 3:29

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi 
The latest snapshot works fine with IE. Thank you for the fix.

--Kiran

Original comment by veeravel...@gmail.com on 6 Jan 2011 at 9:39

GoogleCodeExporter commented 9 years ago
I am using the latest snapshot, but the ServerResponse always starts with 
"GWTU-" and strips away the two XML tags that were infront of it. I am using 
fiddler to check what the server is delivering, and the response comes out fine 
from the server. I have tried looking at it via the Development mode in Debug, 
but everywhere I look, I see the truncated Output. 

Original comment by per.ab...@gmail.com on 19 Jan 2011 at 1:35

GoogleCodeExporter commented 9 years ago
I have tried something stupid: I have added the following to my ServletCode:

response="GWTU-"+response;

and now the response is complete - with GWTU- prepended to the 
"servletResponse".

Is there some placve in the code, where U are searching the response for 
"GWTU-"?

Original comment by per.ab...@gmail.com on 19 Jan 2011 at 1:39

GoogleCodeExporter commented 9 years ago

Original comment by manuel.carrasco.m on 7 Feb 2011 at 6:34