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);
查看全文
相关阅读:
nginx配置虚拟主机
Nginx 目录结构
Day 12.1模拟赛游记
Day 11.25模拟赛游记
Day 11.20模拟赛游记
Day 11.19模拟赛游记
Day 11.17模拟赛游记
【题解报告】P3797 妖梦斩木棒
8-28练习报告
二分图匹配与树链剖分
原文地址:https://www.cnblogs.com/soundcode/p/2966096.html
最新文章
nginx开机自起服务
简单python日志抓取脚本
SHELL脚本学习-自动生成AWR报告
SHELL脚本学习-定时检查Oracle alert日志并发送mail
Vmware Workstation实现CentOS6.10_x64 下ORACLE RAC 11.2.0.4的搭建
天兔(Lepus)数据库监控系统安装笔记
SHELL脚本学习-练习写一个脚本4
SHELL脚本学习-练习写一个脚本3
shell脚本学习-练习写一个脚本2
shell脚本学习-练习写一个脚本1
热门文章
xtrabackup命令用法实战(转)
Percona XtraBackup使用说明(转)
RabbitMQ-基础
AMQP
Zookeeper的安装与使用
zookeeper应用场景
Zookeeper是什么
nginx负载均衡
nginx Location正则表达式
nginx反向代理
Copyright © 2011-2022 走看看