468,554 Members | 1,966 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,554 developers. It's quick & easy.

sending data to another server

Hi friends..
am having one problem while reading an xml file and sending the
contents by HTTP POST to another server..but i am facing the error like
->Cannot send a content-body with this verb-type.<?xml version="1.0"
encoding="utf-8"?>

am mentioning the code below..

WebRequest webreq;
WebResponse webres;
webreq =
WebRequest.Create("http://localhost/test/Testupload/testxml.xml");

webres = webreq.GetResponse();
StreamReader sReader = new
StreamReader(webres.GetResponseStream());
string strData = sReader.ReadToEnd();
webres.Close();

//Post data
string querystring = strData.ToString();
webreq.ContentType = "multipart/form-data";
webreq.Method = "POST";
Stream strNewStream = webreq.GetRequestStream();
byte[] temp_byteArray;
temp_byteArray =(new
UnicodeEncoding()).GetBytes(querystring);
strNewStream.Write(temp_byteArray, 0,
temp_byteArray.Length);
strNewStream.Close();
HttpContext.Current.Response.Write(querystring);

Kindly help me in solving the problem..In case am wrong in the above
code then plz mention the correct way to solve the problem as soon as
possible..
Regards
Priyabrata

Dec 14 '06 #1
1 1684
Hi, Pintu,
Try using the content type=text/xml
Thanks,
Nis
pintu wrote:
Hi friends..
am having one problem while reading an xml file and sending the
contents by HTTP POST to another server..but i am facing the error like
->Cannot send a content-body with this verb-type.<?xml version="1.0"
encoding="utf-8"?>

am mentioning the code below..

WebRequest webreq;
WebResponse webres;
webreq =
WebRequest.Create("http://localhost/test/Testupload/testxml.xml");

webres = webreq.GetResponse();
StreamReader sReader = new
StreamReader(webres.GetResponseStream());
string strData = sReader.ReadToEnd();
webres.Close();

//Post data
string querystring = strData.ToString();
webreq.ContentType = "multipart/form-data";
webreq.Method = "POST";
Stream strNewStream = webreq.GetRequestStream();
byte[] temp_byteArray;
temp_byteArray =(new
UnicodeEncoding()).GetBytes(querystring);
strNewStream.Write(temp_byteArray, 0,
temp_byteArray.Length);
strNewStream.Close();
HttpContext.Current.Response.Write(querystring);

Kindly help me in solving the problem..In case am wrong in the above
code then plz mention the correct way to solve the problem as soon as
possible..
Regards
Priyabrata
Dec 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by coder_1024 | last post: by
3 posts views Thread by Ant | last post: by
7 posts views Thread by John Bailo | last post: by
reply views Thread by pintu | last post: by
31 posts views Thread by happyse27 | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.