XML being posted to my ASPXhttp://forums.asp.net/t/311974.aspx/1?XML+being+posted+to+my+ASPXMon, 18 Aug 2003 20:40:11 -0400311974311974http://forums.asp.net/p/311974/311974.aspx/1?XML+being+posted+to+my+ASPXXML being posted to my ASPX i really need urgent help with this one, a vendor that we use is going to post XML data to one of my ASPX pages. There is nothing really in that ASPX page, they just requested a page where they can POST XML (I imagine, using a method like XMLHTTP or similar). Now, I need to read the XML that is being posted to that file (hopefully in the same file), and parse through it... all the examples I have gotten so far offer me XML files that are viewable through a broswer, so the code simple does Webrequest.Create(URL) but in this case I dont know if i can use that, as the URL is THE SAME FILE that is being posted at.... how can I do this? any help appreciated 2003-08-18T13:36:38-04:00312172http://forums.asp.net/p/311974/312172.aspx/1?Re+XML+being+posted+to+my+ASPXRe: XML being posted to my ASPX If a vendor is posting the XML to you, then you simply need to &quot;catch&quot; the XML and process it, right? <pre class="prettyprint">XmlTextReader reader = new XmlTextReader(Request.InputStream); while(reader.Read()) { //Process the XML here } reader.Close();</pre> You can also do the same with an XmlDocument: <pre class="prettyprint"> XmlDocument doc = new XmlDocument(); doc.Load(Request.InputStream); //process the XML here </pre> 2003-08-18T16:30:33-04:00312222http://forums.asp.net/p/311974/312222.aspx/1?Re+XML+being+posted+to+my+ASPXRe: XML being posted to my ASPX Kirk , I appreciate your response a lot let me tell you what i have: I am sending this XML document via an ASP file (for testing purposes... ): <pre class="prettyprint">Set xmlhttp = CreateObject(&quot;MSXML2.ServerXMLHTTP&quot;) Set xmlDOC =CreateObject(&quot;MSXML.DOMDocument&quot;) xmlDOC.load(&quot;C:\Inetpub\wwwroot\testWeb\testSend.xml&quot;) xmlhttp.Open &quot;POST&quot;, &quot;http://localhost/testWeb/testRecieve.aspx&quot;, False xmlhttp.setRequestHeader &quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot; xmlhttp.send xmlDoc Set xmlhttp = Nothing %&gt;</pre> now I am recieving with the ASPX file like: <pre class="prettyprint"> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim reader As New XmlTextReader(Request.InputStream) While reader.Read 'nothing here, just a debug stop in the previous line End While End Sub </pre> as you see, i am trying to use your example, without any XML processing. I stop the debugger in the loop and the I just add a watch to the reader object... but what I see doesnt seem to be right, the reader loops only 3 times, and the xml file has lots of lines (like 300) .. shouldnt it be looping that much? it looks like the XML file is not being sent correctly.... or the problem is when i recieve it? aahhgg ,, i with i could see a simplified example of both sides, but i haven't been able to find a good one on the net 2003-08-18T17:08:11-04:00312439http://forums.asp.net/p/311974/312439.aspx/1?Re+XML+being+posted+to+my+ASPXRe: XML being posted to my ASPX There are a couple good troubleshooting tools you can use for this. One is tcpTrace, available at PocketSoap.com. This tool lets you see the data posted to your web server. This would be useful to see the entire request body to see if additional data is in the post that you are not accounting for. Another tool to try is simply saving the Request. You can use Request.Save, providing a file name to save the data to. This will let you see if the data is really sent from the ASP page like you think it is. It may be the case that the data is not being sent like you think it is. Something else to check: if the POST from the ASP page is really just XML, then you might try changing the contenttype header to &quot;text/xml&quot;. Finally, the XmlReader might only be looping 3 times because the XML only contains 1 element with a lot of attributes and text content. The line length itself does not matter, the number of elements is significant. Are you sure you are not getting an exception during the parsing? If the XmlReader cannot parse the XML, it should throw an exception. 2003-08-18T19:47:19-04:00312481http://forums.asp.net/p/311974/312481.aspx/1?Re+XML+being+posted+to+my+ASPXRe: XML being posted to my ASPX I can see the request object while I debug, but .. what property should I look at? This vendor just tells me they are using the HTTP POST... so that means that Reading the Request.InputStrem is enough? So this is not like an HTML POST where there I have to request an item in the request collection, like Request.Form(0)? ... Now I am testing this code, to try and get it working in any possible way: <pre class="prettyprint">Dim req As WebRequest = WebRequest.Create(&quot;http://localhost/Web/resident.xml&quot;) 'Dim req As WebRequest = WebRequest.Create(&quot;http://p.moreover.com/cgi-local/page?c=XML%20and%20metadata%20news&amp;o=xml&quot;) Dim resp As WebResponse = req.GetResponse Dim reader As New XmlTextReader(resp.GetResponseStream) Dim doc As New XmlDocument doc.Load(reader) the first two declarations are trying to request an xml file, and both are valid xml files (from what I can see).. the second one is on the internet actually; when i use this seconde one the doc object gets populated with XML, but when I use the first one the debugger in VS.NET doesnt even stop, just displays a blank browser and the doc object doesnt populate anything... it doesnt even error out.... ;(</pre> 2003-08-18T20:28:48-04:00