473,465 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to Remove Http header from http response

I want to receive XML stream generated at another URL however when I
try to load the XML it errors out with one error or the other. I
beleive this XML comes back with HTTP header which actually comes back
as part of the response and obviously causes the
xmlDoc.Load(myResponseStream) to break because the test preceding the
XML makes the xml invalid.

How can I remove this content from the receiving XML stream ?? Here is
some sample code :

..NET Page receiving response

sub Page_Load(sender as object, e as Eventargs)

* Dim wRequest As System.Net.HttpWebRequest
Dim wResponse As System.Net.HttpWebResponse
Dim StreamHandler As System.IO.StreamReader
Dim xmlDoc As New System.Xml.XmlDocument

Try
Dim URL As String = "http://localhost/aspnet/process.asp"
wRequest = System.Net.WebRequest.Create(URL)
wRequest.Headers.Add("Man", "GET " & URL)
wResponse = CType(wRequest.GetResponse,
System.Net.WebResponse)
If wRequest.HaveResponse Then
if wResponse.StatusCode = Net.HttpStatusCode.OK Then
streamHandler = New
System.IO.StreamReader(wResponse.GetResponseStream ())
xmlDoc.LoadXml(StreamHandler.ReadToEnd)
MsgBox("[--------" & xmlDoc.InnerText & "-------]")
End If
End If

'Catch ex As System.Net.WebException
Finally
End Try
end sub
*
I always get error at xmldoc.loadXML

Here is the Process.asp to which the call is being made above to send
XML stream.

<html><head> <title>process</title></head>
<body>
<form id="Form1" method="post" runat="server">
<script LANGUAGE="VBSCRIPT" runat="server" >

Response.Buffer=True
Response.ContentType = "text/xml"

With Response

.Write("<?xml version='1.0' ?>" & chr(13))
.Write("<Record>")
.Write("<Name>")
.Write("<Last> Jones </Last>")
.Write("<First> Kim </First>")
.Write("</Name>")
.Write("</Record>" )
End With
</script>
</form>
</body>
</html>
I would really appreciate any help on this.
Jul 20 '05 #1
3 9364


Vivek Mehta wrote:
I want to receive XML stream generated at another URL however when I
try to load the XML it errors out with one error or the other. I
beleive this XML comes back with HTTP header which actually comes back
as part of the response and obviously causes the
xmlDoc.Load(myResponseStream) to break because the test preceding the
XML makes the xml invalid.

How can I remove this content from the receiving XML stream ?? Here is
some sample code :

.NET Page receiving response

sub Page_Load(sender as object, e as Eventargs)

Dim wRequest As System.Net.HttpWebRequest
Dim wResponse As System.Net.HttpWebResponse
Dim StreamHandler As System.IO.StreamReader
Dim xmlDoc As New System.Xml.XmlDocument

Try
Dim URL As String = "http://localhost/aspnet/process.asp"
wRequest = System.Net.WebRequest.Create(URL)
wRequest.Headers.Add("Man", "GET " & URL)
wResponse = CType(wRequest.GetResponse,
System.Net.WebResponse)
If wRequest.HaveResponse Then
if wResponse.StatusCode = Net.HttpStatusCode.OK Then
streamHandler = New
System.IO.StreamReader(wResponse.GetResponseStream ())
xmlDoc.LoadXml(StreamHandler.ReadToEnd)
MsgBox("[--------" & xmlDoc.InnerText & "-------]")
End If
End If

I don't see any need to use all that code to read in the response and
later call loadXML, you can simply use the Load method and pass the URL
of that ASP page e.g.
xmldoc.Load(URL);
I always get error at xmldoc.loadXML

Here is the Process.asp to which the call is being made above to send
XML stream.

<html><head> <title>process</title></head>
<body>


If you want to output XML then you can't have the HTML in your page,
throw that out.


--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
me*****@hotmail.com (Vivek Mehta) writes in article <14**************************@posting.google.com > dated 10 Aug 2004 20:55:18 -0700:
I want to receive XML stream generated at another URL however when I
try to load the XML it errors out with one error or the other. I
beleive this XML comes back with HTTP header which actually comes back
as part of the response and obviously causes the
xmlDoc.Load(myResponseStream) to break because the test preceding the
XML makes the xml invalid.


The convention (sorry I don't know which RFC) for separating header from
content is a blank line. In other words, two newlines or linefeeds in a
row. If you write a short loop to read and discard everything until that,
what follows will be pure content.

--Keith Lewis klewis {at} mitre.org
The above may not (yet) represent the opinions of my employer.
Jul 20 '05 #3
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41********@olaf.komtel.net>...
Vivek Mehta wrote:
I want to receive XML stream generated at another URL however when I
try to load the XML it errors out with one error or the other. I
beleive this XML comes back with HTTP header which actually comes back
as part of the response and obviously causes the
xmlDoc.Load(myResponseStream) to break because the test preceding the
XML makes the xml invalid.

How can I remove this content from the receiving XML stream ?? Here is
some sample code :

.NET Page receiving response

sub Page_Load(sender as object, e as Eventargs)

Dim wRequest As System.Net.HttpWebRequest
Dim wResponse As System.Net.HttpWebResponse
Dim StreamHandler As System.IO.StreamReader
Dim xmlDoc As New System.Xml.XmlDocument

Try
Dim URL As String = "http://localhost/aspnet/process.asp"
wRequest = System.Net.WebRequest.Create(URL)
wRequest.Headers.Add("Man", "GET " & URL)
wResponse = CType(wRequest.GetResponse,
System.Net.WebResponse)
If wRequest.HaveResponse Then
if wResponse.StatusCode = Net.HttpStatusCode.OK Then
streamHandler = New
System.IO.StreamReader(wResponse.GetResponseStream ())
xmlDoc.LoadXml(StreamHandler.ReadToEnd)
MsgBox("[--------" & xmlDoc.InnerText & "-------]")
End If
End If

I don't see any need to use all that code to read in the response and
later call loadXML, you can simply use the Load method and pass the URL
of that ASP page e.g.
xmldoc.Load(URL);
I always get error at xmldoc.loadXML

Here is the Process.asp to which the call is being made above to send
XML stream.

<html><head> <title>process</title></head>
<body>


If you want to output XML then you can't have the HTML in your page,
throw that out.

Thanks Martin. You were right XMLDoc.Load(URL) works however my XML
response will be coming from five different databases and I would like
to wait and reject a stream if I don't get a response within the
timeframe I need. I was thinking of using webRequest.timeout feature
to track the amount of time it is taking to capture xml response. Is
there something that can be done with XMLDoc.LOAd(URL) method ?

I removed HTML from ASP page and and the page is only outputting XML
now and I am able to load it now.
Jul 20 '05 #4

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

Similar topics

0
by: jacob c. | last post by:
When I request a URL using urllib2, it appears that urllib2 always makes the request using HTTP 1.0, and not HTTP 1.1. I'm trying to use the "If-None-Match"/"ETag" HTTP headers to conserve...
8
by: turnit \(removethis\) | last post by:
I have a login form that uses the post method to carry the information to the next page. The form works just fine in ie6.0, but fails in mozilla and fails in ie5.2 on a mac. "HTTP/1.1 400 Bad...
5
by: Shelly | last post by:
hi, I am trying to create a custom HTTP header and trying to access that variable on another ASP.NET webpage. Following is the code base- I use the following code to set the header...
7
by: Robert Adkison | last post by:
I need to print a web page. It is my preference that my users just do a File/Print from explorer. That way my users will get the print dialog that will allow them to select the fax printer. The...
3
by: Christian Lutz | last post by:
Hy there I have a Web Services written in Java, running on Tomcat. The Client is written in C#. When i monitor the request/Response with TCPMon (included in Tomcat) i can observer the following...
1
by: Nuno Magalhaes | last post by:
I'm doing a "low level" project that consists on monitoring certain QoS parameters such as: Time to resolve dns, time to connect, time to receive data, time to receive all web page, time to close...
3
by: webEater | last post by:
Hey, I am writing a file that reads in an external file in the web and prints it out including the response header of the http protocol. I do this to enable cross domain XMLHttpRequests. I...
3
by: Reporter | last post by:
Here is an example from the PHP Manual <?php if ((!isset($_SERVER)) || (1==1)) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'Text to send...
4
by: sebsauvage | last post by:
Hello. I'm using SimpleHTTPServer (work well) but it always sends "Server" header in response: "Server: SimpleHTTP/0.6 Python/2.5.1" How can I remove that ? I tried:
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.