473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Post XML from one C# web app to another

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()+".x ml");

Apr 28 '06 #1
3 9644
what is the value of "url" when it fails?

Cheers,

Greg
<ra*******@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
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()+".x ml");

Apr 28 '06 #2
what is the value of "url" when it fails?

Cheers,

Greg
<ra*******@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
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()+".x ml");

Apr 28 '06 #3
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

Apr 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: luu duong | last post by:
I know this is probably easy but here is the details. I have an asp page that is not inside a frameset. I want to post data to another asp page that is inside a frameset. So firstpage.asp has...
6
by: anon | last post by:
Post Forwarding question...... For this control below, <asp:Button runat="server" PostTargetUrl="page2.aspx" /> The Attribute: PostTargetUrl="page2.aspx" Is this PostTargetUrl Attribute...
8
by: Victor | last post by:
I need to redirect to another web page, but that redirect will include the submission of form data. So, unlike ServerXMLHTTP which stays on the originating web page, I need the script to redirect...
5
by: Jack | last post by:
Hi, I am trying to find rows where a memo field in table1 contains the text in table2. Example: table1.memo contains: row 1: This is a long sentence that goes on and on... row 2: This is...
7
by: Matt | last post by:
Hi all, Not very sure about this. I have one button (not a submit button) will "post" partial page(form) info to another url(the user will also redirect to this url :-). I dont' want to change...
2
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser ...
1
by: Manuel | last post by:
I have to log into a website and retrieve some information. The problem is that the post isn't "normal". I'm used to passing post values in the form of: Variable1=Value1&Variable2=Value2 etc. I...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
3
by: gustav | last post by:
Hey there, I have this problem: I´m migrating an ASP site to ASP.NET 1.1, and I find myself stuck because of this Form that has some inputs to access an Extranet... When the user submits, the...
5
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
I am trying to create ASPX code which will allow me to redirect a user to another site with POST data. I figure that the best way to do this is with JavaScript to the client. Here's what I'm doing:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.