通过http/https的POST方式,发送处理和接收XML文件内容
Posted lee576
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过http/https的POST方式,发送处理和接收XML文件内容相关的知识,希望对你有一定的参考价值。
1.send:
2.receive:
-
C# code
-
WebRequest myHttpWebRequest = WebRequest.Create( " http://abc.com/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 version= " 1.0 " encoding= " UTF - 8 " ?>
< ROOT >
< CONFIG >
< TYPE > IN </ TYPE >
< WORKTYPE > 2 </ WORKTYPE >
</ CONFIG >
< DATA >
< POLICY >
< UNITCODE > 分公司代码 </ UNITCODE >
< APPLYNO > 投保单号码 </ APPLYNO >
< APPLYENDORSENO > 批单申请号码 </ APPLYENDORSENO >
</ POLICY >
</ DATA >
</ ROOT > " ;
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();
2.receive:
-
C# code
-
StreamReader reader = new StreamReader (Reqeust.InputStream);
String xml = reader.ReadToEnd();
以上是关于通过http/https的POST方式,发送处理和接收XML文件内容的主要内容,如果未能解决你的问题,请参考以下文章
以快递方式从 POST 请求处理程序发送 WebSocket 消息
HttpUtils 发送HTTP/HTTPS/{get/post}请求
nodejs通过代理(proxy)发送http请求(request)
C#带cookie Post和Get方式发送数据,保持cookie
为啥用ajax发送post请求时,需要设置请求头类型为application/x-www-form-urlencoded