472,351 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 9323


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...
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...
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...
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...
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...
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...
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...
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"');...
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...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.