How to post XML to the interface as a parameter in C #

Source: Internet
Author: User

String xml = "<DATA> Chinese </data> ";
String postdata = "Data =" + server. urlencode (XML );;
String strurl = "http: // localhost: 29833/website1/XX. aspx ";
// Prepare the request...
Httpwebrequest myrequest = (httpwebrequest) webrequest. Create (strurl );
Myrequest. method = "Post ";
Myrequest. contenttype = "application/X-WWW-form-urlencoded ";
Myrequest. contentlength = postdata. length;
Stream newstream = myrequest. getrequeststream ();
Byte [] DATA = encoding. getencoding ("gb2312"). getbytes (postdata );
// Send data
Newstream. Write (data, 0, Data. Length );
Httpwebresponse res = myrequest. getresponse () as httpwebresponse;
Streamreader sr = new streamreader (res. getresponsestream (), encoding. utf8 );
String ret = Sr. readtoend ();
Newstream. Close ();
Response. Write ("You submitted:" + server. htmlencode (RET ));

// ==============

Receive Interface
Response. clearcontent ();
Response. Write (request. Form ["data"]);
Response. End ();

 

 

From: http://topic.csdn.net/u/20101117/11/bfee4a29-d966-4870-9026-0243767067a6.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.