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);
查看全文
相关阅读:
根据现有文件生成图形化的目录树
一个最简的短信验证码倒计时例子
将指定目录下的所有资源整体迁移到另一个目录下
通过 url 获取相应的 location 信息
node-glob的*匹配
mysql将查询出来的一列数据拼装成一个字符串
Call to undefined function mysql_connect()错误原因
JavaScript转unix时间戳
.net3.0 中跨线程访问控件
WPF的线程模型
原文地址:https://www.cnblogs.com/soundcode/p/2966096.html
最新文章
「数据分析」Sqlserver中的窗口函数的精彩应用-问题篇
Excel催化剂开源第51波-Excel催化剂遍历单元格操作性能保障
「PowerBI」Tabular Editor 一个对中文世界很严重的bug即将修复完成
Excel催化剂开源第50波-Excel与PowerBIDeskTop互通互联之第四篇
Excel催化剂开源第49波-Excel与PowerBIDeskTop互通互联之第三篇
Excel催化剂开源第48波-Excel与PowerBIDeskTop互通互联之第二篇
Android linearlayout常用布局
Android 四种简单的动画(淡入淡出、旋转、移动、缩放效果)
asp.net开发中经常用到的方法
Android activity之间传值关键性代码
热门文章
Android通过webservice对sqlserver数据库进行操作
kubernetes 之ingress
kubernetes 数据持久化之Glusterfs
分布式文件系统之Glusterfs
Kubectl管理工具
kubernetes 之容器监控
kubernetes-dashboard
kubernetes 之dns 服务发现
docker 集群 flannel网络构建
命令行神器 cmder
Copyright © 2011-2022 走看看