application/xml and text/xml的区别
经常看到有关xml时提到"application/xml" 和 "text/xml"两种类型, 二者功能一模一样,唯一的区别就是编码格式,text/xml忽略xml头所指定编码格式而默认采用us-ascii编码,而application/xml会根据xml头指定的编码格式来编码:
XML has two MIME types,application/xml and text/xml . These are often used interchangeably, but there is a subtle difference which is why application/xml is generally recommended over the latter.
Let me explain why: according to the standard, text/* -MIME types have a us-ascii character set unless otherwise specified in the HTTP headers. This effectively means that any encoding defined in the XML prolog (e.g. <?xml version=”1.0” encoding=”UTF-8”?>) is ignored. This is of course not the expected and desired behaviour.
To further complicate matters, most/all browser implementations actually implement nonstandard behaviour for text/xml because they process the encoding as if it were application/xml .
So, text/* has encoding issues, and is not implemented by browsers in a standards-compliant manner, which is why using application/* is recommended.
text/xml 和 application/xml的字符集编码问题
关键字: text/xml application/xml
对于Webservice的应用来说,我们通常都是用UTF-8进行网络传输,但也有通过GBK和GB2312传输的情况,但是在我们Webservice的代码实现中,其实是不用关心具体的传输编码的,因为根据RFC2376的定义,Webservice的引擎(axis,cxf,jaxws..)会根据文件传输的ContentType及XML 声明部分定义的编码自动将网络传输过来的内容(字符串)转换成unicode(jvm运行时的字符串都是以unicode形式存在的)。以下是RFC2376的描述:
分享到:
相关推荐
".biz"="text/xml" ".bmp"="application/x-bmp" ".bot"="application/x-bot" ".c4t"="application/x-c4t" ".c90"="application/x-c90" ".cal"="application/x-cals" ".cat"="application/vnd.ms-pki.seccat" ".cdf"=...
通常前端通过POST请求向服务器端提交数据格式有4中,分别是”application/x-www-form-urlencoded”格式、” multipart/form-data”格式、”application/json”格式和”text/xml”格式。通常最常见的是”application/...
// 提交方式 public static String REQUEST_METHOD_POST = "POST... public static String MIME_TYPE_TEXTXML = "text/xml;charset=utf-8"; public static String MIME_TYPE_TEXTPLAIN = "text/plain;charset=utf-8";
C# RestClient组件下载,...application/xml XML application/x-www-form-urlencoded Form表单 text/plain 纯文本 text/xml XML文本 text/html HTML文本 multipart/form-data 用于上传文件 application/xhtml+xml XHTML
Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <short xmlns="http://webi.org">short</short>*/ //出参是json格式{"statusCode":"2"}
响应 body 的 Content-Type 为 text/xml、text/plain、text/css、application/javascript、app
"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Encoding": "gzip, deflate, br", "Accept-Language": "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3", "Connection":"keep-...
Accept: text/html,application/xhtml+xml,application/xml;q=0.9, / ;q=0.8 而Windows 7上的Chrome浏览器可能会发送: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng, ...
... #define SERVER_ADDR "123.207.48.25" #define SERVER_PORT 10001 #define SERVER_URL "123.207.48.25" #define SERVER_PATH "/photo/" ... "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
import urllib.request ...headers = { ... "Connection":"keep-alive", ... "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Referer":"http://www.renren
.svg image/svg+xml 2、index.html为首页,默认没有加载文件。 3、player.html为播放页,默认播放当着文件夹中的aa.sb3文件 web.config、up.aspx、up.aspx.cs三个文件是.net平台用来在线保存用。
XML:“application/xml“; JSON:“application/json“. dataType为xml的时候,response.Write(string)中的字符串一定要符合xml的格式, 为json的时候,response.Write(string)中的字符串一定要符合json的格式为...
正是这种区别使得XML在网络应用和信息共享上方便,高效,可扩展。所以我们相信,XML做为一种先进的数据处理方法,将使网络跨越到一个新的境界。 六. XML的严格格式 吸取HTML松散格式带来的经验教训,XML一开始就坚持...
"password":"xbw12138",'Accept': 'text/html,application/xhtml+xml,application/xml
否则,请选择 application/xml, text/plain 或通配符,或者输入自定义媒体类型。 输入HTTP基本身份验证信息,如果服务器端需要验证。其它认证方法,如OAuth, 将在未来得到支持。 输入HTTP头部信息,如果服务器端需要...
'atom' => 'application/atom xml', 'au' => 'audio/basic', 'avi' => 'video/x-msvideo', 'bcpio' => 'application/x-bcpio', 'bin' => 'application/octet-stream', 'bmp' => 'image...
剩余存根 Rest stub是一个简单的轻量级应用程序,可以在docker容器中运行,从而允许用户在某些路径下以罐装... ./text/json/test.xml /test text/html ./text/html/test.xml /user/3453312 application/json .
gzip_min_length 5k;...gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;gzip_vary on; 配置指令详细注释:g
于是就深入的查了一下,原来PHP默认只识别application/x-www.form-urlencoded标准的数据类型,因此,对型如text/xml 或者 soap 或者 application/octet-stream 之类的内容无法解析,如果用$_POST数组来接收就会失败...
如果 Accept 标头是 application/xml 或 text/xml,则两者都返回 HTTP 错误代码 406(不可接受)。 0.0.1-M2 JSON 和 XML 服务都在工作……感谢 bean 类上的 @XmlRootElement 注释。 0.0.1-M3 使用 Spring Boot ...