request 报错The remote server returned an error: (415) Unsupported Media Type.
开发时遇到个问题,程序访问数据库数据,给服务器发送请求时,老是报错,返回的错误页面是:
HTTP Status 415 - Unsupported Media Type type Status report message Unsupported Media Type 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啊。
<?xml version="1.0" encoding="UTF-8"?>
好吧 ,然后自己又去手动设置请求中的头部,这下XML的编码格式就应该没错了吧。
Dim AppDatbus As New MSXML2.XMLHTTP
AppDatbus.setRequestHeader("CONTENT-TYPE", "text/xml")
后来发现还是没用,求助微软大神以后,找到一份看起来好像很吊的文章,虽然看不懂,但是还是拿出来跟大家分享下,觉得自己或是大家以后也许用得上:
如何通过使用 XMLHTTP 或 ServerXMLHTTP 对象提交窗体数据
当自己手足无措的时候,数据库大叔来了句,我帮你看看,依旧改了请求头部,只是改成了
Dim AppDatbus As New MSXML2.XMLHTTP
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.的更多相关文章
- 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 ...
- Call Azure Queue get "The remote server returned an error: (400) Bad Request."
这几天开始研究Windows Azure, 在使用Azure Queue 的时候,CreateInfNotExists 总是抛出异常 "The remote server returned ...
- WebService:The remote server returned an error: (400) Bad Request
开发工具:VS2010.开发组件:WebService.运行环境:Windows 今天一个同事在进行计费接口联调试时,发现了一个非常奇怪的问题:接口在家里环境测试,一切正常,但是部署到现网环境之后,连 ...
- 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 ...
- Darwin Streaming Server服务器mp4文件点播返回”415 Unsupported Media Type“错误
Darwin Streaming Server中mp4文件点播失败,通过抓包发现服务器返回”415 Unsupported Media Type“错误,如下: RTSP/ Unsupported Me ...
- WP8 调用webservice 错误 The remote server returned an error: NotFound 解决
本人出错是由于本地的IIS不能被局域网其它机器访问导致的,如果你所用的本机IIS 也不可被其它机器访问,则可按照本文进行设置 具体操作时需要在防火墙设置中添加 入站规则 具体步骤如下: 1.控 ...
- 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 ...
- unity 打包Error:WebException: The remote server returned an error: (403) Forbidden.
記一下在ios上打包出錯: UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors at UnityEditor.BuildPlaye ...
- HTTP Status 415 – Unsupported Media Type(使用@RequestBody后postman调接口报错)
1.问题描述:使用springMVC框架后,添加数据接口中,入参对象没使用@RequestBody注解,造成postman发起post请求, from-data可以调通接口,但是raw调不通接口,然后 ...
随机推荐
- STM32F072B-DISCO 深入研究 USB系统
调试USB例题需要用到2个上位机程序: PC端HID交互程序,提供了VC源程序. 图形方式的按钮输入.LED输出操作: 总线扑捉器: main程序初始化部分很简单: /* Initialize USB ...
- TCP11种状态分析和测试
-->简介 -->正文 -->测试一些状态 --------------------------------------------------------------------- ...
- 修改maven中的jdk版本
1.修改项目的pom.xml文件 <build> <plugins> <plugin> <groupId>org.apache.maven.plugin ...
- ACM1019_最大公倍数
/*问题说明 一组正整数的最小公倍数(LCM)是最小的正整数约数集合中的所有号码. 例如,5,7和15的最小公倍数是105. 输入 输入将包括多个问题的实例.输入的第一行中,将包含一个整数, 表示问题 ...
- mysql使用mysqldump导出数据出错
mysqldump -hlocalhost -uroot -p123456 student_info jssypk > c:/databackup.sql 导出表结构 mysqldump - ...
- 使用Spring-data-redis操作Redis的Sentinel
介绍 Spring-Data-Redis项目(简称SDR) 是对Redis的Key-Value数据存储操作提供了更高层次的抽象,提供了一个对几种主要的redis的Java客户端(例 如:jedis,j ...
- C# 应用正则表达式
1.检测该字符串是否 带有字符“8”(类似sql语句:select * from tableName where name like '%8%') string pattern = @"\w ...
- 【转】CPU调度
转自:http://blog.csdn.net/xiazdong/article/details/6280345 CPU调度 用于多道程序 以下先讨论对于单CPU的调度问题. 回顾多道程序,同时把 ...
- 在Tomcat下部署web项目
每个web项目可以以两种方式存在,如联合风控项目,Urc.war,另一中是Urc解压后的目录结构.而tomcat目录下的\webapps\下则均是要部署的web项目解压后的文件夹,启动tomcat后, ...
- The app references non-public selectors in Payload
上周上传app到appstore在validation完后有警告提示"The app references non-public selectors in Payload/wacao.app ...