开发时遇到个问题,程序访问数据库数据,给服务器发送请求时,老是报错,返回的错误页面是:

  1. HTTP Status 415 - Unsupported Media Type
  2.  
  3. type Status report
  4.  
  5. message Unsupported Media Type
  6.  
  7. description The server refused this request because the request entity is in a format not supported by the requested resource for the requested method (Unsupported Media Type).

在 百度了各位大神的意见,说法各异,但是都解决不了问题。在一个论坛里终于找到了这个问题的实质:错误提示不支持的媒介类型,原因是XML文件的编码格式与 服务器的编码格式不一致,所以导致出错。屁颠屁颠跑去问管理服务器的那个宅男大叔,然后说是UTF-8。我瞬间雷到了,因此自己的表头文件格式就是 UTF-8啊。

  1. <?xml version="1.0" encoding="UTF-8"?>

好吧 ,然后自己又去手动设置请求中的头部,这下XML的编码格式就应该没错了吧。

  1. Dim AppDatbus As New MSXML2.XMLHTTP
  2. AppDatbus.setRequestHeader("CONTENT-TYPE", "text/xml")

后来发现还是没用,求助微软大神以后,找到一份看起来好像很吊的文章,虽然看不懂,但是还是拿出来跟大家分享下,觉得自己或是大家以后也许用得上:

如何通过使用 XMLHTTP 或 ServerXMLHTTP 对象提交窗体数据

当自己手足无措的时候,数据库大叔来了句,我帮你看看,依旧改了请求头部,只是改成了

  1. Dim AppDatbus As New MSXML2.XMLHTTP
  2. AppDatbus.setRequestHeader("CONTENT-TYPE", "application/xml")


己查找资料发现:"application/xml" 和 "text/xml"两种类型,
二者功能一模一样,唯一的区别就是编码格式,text/xml忽略xml头所指定编码格式而默认采用us-ascii编码,而application
/xml会根据xml头指定的编码格式来编码:

具体的文章网址如下,有兴趣深究可以看下:application/xml and text/xml的区别

request 报错The remote server returned an error: (415) Unsupported Media Type.的更多相关文章

  1. System.Net.WebException : The remote server returned an error: (415) UNSUPPORTED MEDIA TYPE

    I am having problems with a bit of code that accesses a restful web service. Running this code, it e ...

  2. Call Azure Queue get "The remote server returned an error: (400) Bad Request."

    这几天开始研究Windows Azure, 在使用Azure Queue 的时候,CreateInfNotExists 总是抛出异常 "The remote server returned ...

  3. WebService:The remote server returned an error: (400) Bad Request

    开发工具:VS2010.开发组件:WebService.运行环境:Windows 今天一个同事在进行计费接口联调试时,发现了一个非常奇怪的问题:接口在家里环境测试,一切正常,但是部署到现网环境之后,连 ...

  4. EWS code return Error : Request failed. The remote server returned an error: (403) Forbidden OR (401) Unauthorized

    Following is my code. ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1 ...

  5. Darwin Streaming Server服务器mp4文件点播返回”415 Unsupported Media Type“错误

    Darwin Streaming Server中mp4文件点播失败,通过抓包发现服务器返回”415 Unsupported Media Type“错误,如下: RTSP/ Unsupported Me ...

  6. WP8 调用webservice 错误 The remote server returned an error: NotFound 解决

    本人出错是由于本地的IIS不能被局域网其它机器访问导致的,如果你所用的本机IIS 也不可被其它机器访问,则可按照本文进行设置   具体操作时需要在防火墙设置中添加 入站规则   具体步骤如下: 1.控 ...

  7. HttpWebRequest WebExcepton: The remote server returned an error: (407) Proxy Authentication Required.

    1. Supply the credentials of the Currently Logged on User to the Proxy object similar to this: // Be ...

  8. unity 打包Error:WebException: The remote server returned an error: (403) Forbidden.

    記一下在ios上打包出錯: UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors at UnityEditor.BuildPlaye ...

  9. HTTP Status 415 – Unsupported Media Type(使用@RequestBody后postman调接口报错)

    1.问题描述:使用springMVC框架后,添加数据接口中,入参对象没使用@RequestBody注解,造成postman发起post请求, from-data可以调通接口,但是raw调不通接口,然后 ...

随机推荐

  1. C++ string 构造的陷阱

    先看代码 #include<iostream> #include<string> using namespace std; int main(int argc, char ** ...

  2. 《Linear Algebra and Its Applications》-chaper6-正交性和最小二乘法- 格拉姆-施密特方法

    构造R^n子空间W一组正交基的算法:格拉姆-施密特方法.

  3. linux 内核驱动加载过程中 向文件系统中的文件进行读写操作

    utils.h 文件: #ifndef __UTILS_H__ #define __UTILS_H__ void a2f(const char *s, ...); #endif utils.c 文件: ...

  4. SSH服务及花生壳域名解析

    一.安装说明以CentOS 5为例 1.安装必要的开发包 [root@localhost ~]# yum install gcc gcc-c++ autoconf automake 2.下载phddn ...

  5. 常用的js效验

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. DSPack各种使用方法

    1. DSPack 2.3.4 安装   一. 下载由于sourceforge最近不能访问,所以可以去 http://www.progdigy.com/ 下载.下载 http://www.progdi ...

  7. jQuery Vlidate 演示样例

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  8. mysql优化21条

    今天一个朋友向我咨询怎么去优化 MySQL,我按着思维整理了一下,大概粗的可以分为21个方向. 还有一些细节东西(table cache, 表设计,索引设计,程序端缓存之类的)先不列了,对一个系统,初 ...

  9. 初步掌握Yarn的架构及原理

    1.YARN 是什么? 从业界使用分布式系统的变化趋势和 hadoop 框架的长远发展来看,MapReduce的 JobTracker/TaskTracker 机制需要大规模的调整来修复它在可扩展性, ...

  10. git常见指令

    master : 默认开发分支: origin : 默认远程版本库 初始化操作    $ git config -global user.name <name> #设置提交者名字    $ ...