`
zyslovely
  • 浏览: 227566 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

application/xml and text/xml的区别

 
阅读更多
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的描述:
分享到:
评论

相关推荐

    文件下载及web文件的contentType类型大全

    ".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"=...

    使用axios发送post请求,将JSON数据改为form类型的示例

    通常前端通过POST请求向服务器端提交数据格式有4中,分别是”application/x-www-form-urlencoded”格式、” multipart/form-data”格式、”application/json”格式和”text/xml”格式。通常最常见的是”application/...

    http/https请求工具类

    // 提交方式 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组件下载,实现请求接口地址

    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

    调用pb开发的webserver(HTTP POST)

    Content-Type: text/xml; charset=utf-8 Content-Length: length &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;short xmlns="http://webi.org"&gt;short&lt;/short&gt;*/ //出参是json格式{"statusCode":"2"}

    tencentyun#qcloud-documents#响应压缩1

    响应 body 的 Content-Type 为 text/xml、text/plain、text/css、application/javascript、app

    在python中使用requests 模拟浏览器发送请求数据的方法

    "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-...

    reap:Clojure库,用于解码和编码Web协议使用的字符串

    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, ...

    Linux 下http post 文件到文件服务器的方法

    ... #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,*/

    07-cookie模拟登陆人人网.py

    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

    Scratch源程序 Scratch html源程序 Scratch3源程序

    .svg image/svg+xml 2、index.html为首页,默认没有加载文件。 3、player.html为播放页,默认播放当着文件夹中的aa.sb3文件 web.config、up.aspx、up.aspx.cs三个文件是.net平台用来在线保存用。

    asp.netajaxupload

    XML:“application/xml“; JSON:“application/json“. dataType为xml的时候,response.Write(string)中的字符串一定要符合xml的格式, 为json的时候,response.Write(string)中的字符串一定要符合json的格式为...

    XML轻松学习手册--XML肯定是未来的发展趋势,不论是网页设计师还是网络程序员,都应该及时学习和了解

    正是这种区别使得XML在网络应用和信息共享上方便,高效,可扩展。所以我们相信,XML做为一种先进的数据处理方法,将使网络跨越到一个新的境界。 六. XML的严格格式 吸取HTML松散格式带来的经验教训,XML一开始就坚持...

    解决学校服务器流量问题方案1

    "password":"xbw12138",'Accept': 'text/html,application/xhtml+xml,application/xml

    基于REST的Web服务客户端v5.6.6

    否则,请选择 application/xml, text/plain 或通配符,或者输入自定义媒体类型。 输入HTTP基本身份验证信息,如果服务器端需要验证。其它认证方法,如OAuth, 将在未来得到支持。 输入HTTP头部信息,如果服务器端需要...

    获取文件的mime typePHP类库.zip

     'atom' =&gt; 'application/atom xml',  'au' =&gt; 'audio/basic',  'avi' =&gt; 'video/x-msvideo',  'bcpio' =&gt; 'application/x-bcpio',  'bin' =&gt; 'application/octet-stream',  'bmp' =&gt; 'image...

    rest-stub

    剩余存根 Rest stub是一个简单的轻量级应用程序,可以在docker容器中运行,从而允许用户在某些路径下以罐装... ./text/json/test.xml /test text/html ./text/html/test.xml /user/3453312 application/json .

    Nginx Gzip模块启用和配置指令详解

    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获取post中的json数据的实现方法

    于是就深入的查了一下,原来PHP默认只识别application/x-www.form-urlencoded标准的数据类型,因此,对型如text/xml 或者 soap 或者 application/octet-stream 之类的内容无法解析,如果用$_POST数组来接收就会失败...

    mpaf-spring-boot-demo

    如果 Accept 标头是 application/xml 或 text/xml,则两者都返回 HTTP 错误代码 406(不可接受)。 0.0.1-M2 JSON 和 XML 服务都在工作……感谢 bean 类上的 @XmlRootElement 注释。 0.0.1-M3 使用 Spring Boot ...

Global site tag (gtag.js) - Google Analytics