Post XML from one C# web app to another

R

ramsamant

Hi,

I am trying to push XML files via HTTP using C#. I am using the free
Visual Studio Web Developer Express to do this. After transferring
about 10-15 files, randomly the files transfer fail and I get
[WebException: The remote server returned an error: (403) Forbidden.]

I've tried on XP as well as Win2003 Server

Thanks for any help

Ram

CODE TO SEND FILES.

StringBuilder sb = new StringBuilder();

byte[] bytes = Encoding.UTF8.GetBytes(xml);
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.Timeout = 300000;
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();




CODE TO RECEIVE FILES

byte[] buf = new byte[Request.ContentLength];
buf=Request.BinaryRead(Request.ContentLength);
string s=Encoding.UTF8.GetString(buf);

StringReader sr=new StringReader(s);
DataSet ds=new DataSet();
ds.ReadXml(sr);

\ds.WriteXml(AppDomain.CurrentDomain.BaseDirectory + "/Received/" +
System.DateTime.Now.ToFileTimeUtc().ToString()+".xml");
 
R

ramsamant

URL remains the same. It is the URL of the receiving application.

I have narrowed it down to the code at the receiving application -
buf=Request.BinaryRead(Request.ContentLength);

I tried it with Request.ToString();

Same thing. It freezes up and returns a 403 error after processing
about 12-15 files.

Thanks,
Ram
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top