zoukankan
html css js c++ java
Request.InputStream 将数据作为XML数据发送
将数据作为XML数据发送,例如:
public
void
PostXml(
string
url,
string
xml)
{
byte
[] bytes
=
Encoding.UTF8.GetBytes(xml);
HttpWebRequest request
=
(HttpWebRequest) WebRequest.Create(url);
request.Method
=
"
POST
"
;
request.ContentLength
=
bytes.Length;
request.ContentType
=
"
text/xml
"
;
using
(Stream requestStream
=
request.GetRequestStream())
{
requestStream.Write(bytes,
0
, bytes.Length);
}
HttpWebResponse response
=
(HttpWebResponse) request.GetResponse();
if
(response.StatusCode
!=
HttpStatusCode.OK)
{
string
message
=
String.Format(
"
POST failed. Received HTTP {0}
"
,
response.StatusCode);
throw
new
ApplicationException(message);
}
}
接收端通过Request.InputStream读取:
byte
[] byts
=
new
byte
[Request.InputStream.Length];
Request.InputStream.Read(byts,
0
,byts.Length);
string
req
=
System.Text.Encoding.Default.GetString(byts);
req
=
Server.UrlDecode(req);
对于完整的XML数据,可以:
xmlDoc
=
new
XmlDocument();
xmlDoc.load(Request.InputStream);
查看全文
相关阅读:
angular手势事件之on-Hold
angular 控制器的使用两种模式
关于IONIC 报错 XX is not a function
ionic 中$ionicView.beforeEnter 事件的一个bug
开发一个IONIC应用的首要操作(宏观)
在线常用库 + API手册
关于日历实现代码里lunarInfo(农历)数组
YSlow
GET and POST
Yahoo34条军规——雅虎WEB前端网站优化
原文地址:https://www.cnblogs.com/soundcode/p/2966096.html
最新文章
数据库用户被锁怎么办,报the passord logon
SpringMVC运行原理
米四度的思考
ElasticSearch服务器操作命令
ElasticSearch集群配置
The program 'unzip' is currently not installed. You can install it by typing:
ElasticSearch java API-使用More like this实现基于内容的推荐
修改ElasticSearch默认的from size
Likely root cause: java.lang.IllegalStateException: jar hell!
ElasticSearch搜索demo
热门文章
SpringBoot 拦截器中校验Json数据
Idea常用插件以及常用设置
SpringBoot中Interceptor和Filter的使用
阿里云短信工具类2020.8.5
SpringBoot-actuator服务监控与管理
接口的意义
JS汉语转拼音脚本
荒废了很久的java以及微信公众平台今天拿起来看了看:这里有很好的教程
java.lang.classNotFound:明明已经导入了jar包,包里也有该类,却找不到的解决方法
CSS3 -webkit-transform
Copyright © 2011-2022 走看看