开发者

IE8 not displaying XML but giving a popup saying "Do you want to save this file?" Why?

I am testing a SOAP service that has a single operation that returns a string containing an XML document. My server and client are implemented in PHP.

Here is the source for my client:

<?php
header('Content-Type: text/xml, charset=iso-8859-1'); 
header("Content-Disposition: inline");
try{
  $sClient = new SoapClient('http://localhost/soap/test.wsdl');
  $response = $sClient->getDocument();
  echo($response);
} catch(SoapFault $e){
   var_dump($e);
}
?>

And this is the XML returned by the SOAP service and echoed by the client:

<?xml version="1.0" encoding="iso-8859-1" ?&开发者_如何学Pythongt;
<root>
<form formname="test">
   <post postid="2000" userid="bbh" postdate="2011-09-14" posttime="11:03:32">
      <item name="Item1" value="123" />
      <item name="Item2" value="456" />
   </post>
</form>
</root>

When I test the SOAP client in Firefox for mac, Firefox for Windows and Safari, the XML returned by the SOAP service is correctly displayed in these browsers. However, when I test it on IE7 (on Windows 2003 Server) I get a blank screen even though I see the XML if I do a view source on the page. When I test it on IE8 (on Windows 7), I get a popup box saying "Do you want to save this file or find a program online to load it?".

Does anyone have any idea why the XML is not being displayed correctly in IE7 and IE8?

UPDATE:

Here are the HTTP headers which I got from Live HTTP headers in Firefox:

http://localhost/soap/testclient.php

GET /soap/testclient.php HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0.1) Gecko/20100101 Firefox/5.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Connection: keep-alive
Cookie: PHPSESSID=bo6dlobivah1iaeu6d53vt9s10
Cache-Control: max-age=0
HTTP/1.1 200 OK
Connection: close

Date: Wed, 14 Sep 2011 11:09:57 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET, PHP/5.2.1
Content-Type: text/xml, charset=iso-8859-1


I guess that's the default action built-in for the XML mime type. You could try commenting the content-type header, or changing the mime type to text/html. Not really nice but could do the trick.


Not sure if this helps, but the header declaration appears to be incorrect

According to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html you should use a ; rather than a , to separate content-type and charset:

header('Content-Type: text/xml; charset=iso-8859-1');

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜