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);
查看全文
相关阅读:
【C#】Color颜色对照表
eslint的实践
关于babel和webpack结合使用的实践
前端学习博客
css学习4--网格布局
css学习3--flexbox布局
CSS学习2-布局介绍
css学习1
前端性能优化
line-height介绍
原文地址:https://www.cnblogs.com/soundcode/p/2966096.html
最新文章
乐观锁与悲观锁
关于注解@SpringBootApplication的一些认识
Spring Boot解析,以HelloWorld为例
Spring Boot对多环境的支持
Spring Boot几个注解的区别,如@ConfigurationProperties和@Value等
在Linux系统下进行Nacos集群的搭建与部署
Nacos-1.3.0 + MySQL-8.0.21 本地单机版配置部署流程
关于新版本Nacos 1.3.2安装启动出现的一系列问题
CentOS 7安装配置ssh和sftp用以实现root用户登录
CentOS 7 停止firewall 安装配置iptables防火墙
热门文章
Linux常用目录及其作用整理
modbus通讯协议
解决加载NIDAQmx 报error 2019的Bug
Windows+ VS2019+C++ Ogre环境搭建的各种坑
基于qwtplot3d的QT 3d 波形显示
数字信号处理(DSP)基本名词术语及其关系
QEM三维模型抽稀算法C++Wraper实例
Linux学习笔记(不断更新。。。)
创建UBUNTU 快捷方式到桌面
ubuntu系统更换源
Copyright © 2011-2022 走看看