首页 新闻 搜索 专区 学院

如何通过https的POST方式,发送,接收XML文件的内容

0
悬赏园豆:100 [已解决问题] 解决于 2008-10-17 19:08

如题!

chenming的主页 chenming | 初学一级 | 园豆:0
提问于:2008-10-16 09:43
< >
分享
最佳答案
0

发送操作:

C# code
WebRequest myHttpWebRequest = WebRequest.Create(http://XXX.aspx);
// Set the 'Method' property of the 'Webrequest' to 'POST'.
myHttpWebRequest.Method = "POST";

// Create a new string object to POST data to the Url.
string postData = //想要发送的XML文件

ASCIIEncoding encoding
= new ASCIIEncoding ();
byte[] byte1 = encoding.GetBytes (postData);

// Set the content type of the data being posted.
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";

// Set the content length of the string being posted.
myHttpWebRequest.ContentLength = byte1.Length;

Stream newStream
= myHttpWebRequest.GetRequestStream ();

newStream.Write (byte1,
0, byte1.Length);
// Close the Stream object.
newStream.Close ();

HttpWebResponse response
= myHttpWebRequest.GetResponse();

 
接收: 
C# code
StreamReader reader = new StreamReader (Reqeust.InputStream);
String xml
= reader.ReadToEnd();
RicoRui | 老鸟四级 |园豆:3663 | 2008-10-16 09:56
其他回答(1)
0

jquery($.ajax)也能胜任客户端的操作

http://jquery-api-zh-cn.googlecode.com/svn/trunk/index.html

Ridge Wong | 园豆:205 (菜鸟二级) | 2008-10-16 13:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册