473,561 Members | 3,118 Online
Bytes | Software Development & Data Engineering Community
+ 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(myR esponseStream) 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(sende r as object, e as Eventargs)

* Dim wRequest As System.Net.Http WebRequest
Dim wResponse As System.Net.Http WebResponse
Dim StreamHandler As System.IO.Strea mReader
Dim xmlDoc As New System.Xml.XmlD ocument

Try
Dim URL As String = "http://localhost/aspnet/process.asp"
wRequest = System.Net.WebR equest.Create(U RL)
wRequest.Header s.Add("Man", "GET " & URL)
wResponse = CType(wRequest. GetResponse,
System.Net.WebR esponse)
If wRequest.HaveRe sponse Then
if wResponse.Statu sCode = Net.HttpStatusC ode.OK Then
streamHandler = New
System.IO.Strea mReader(wRespon se.GetResponseS tream())
xmlDoc.LoadXml( StreamHandler.R eadToEnd)
MsgBox("[--------" & xmlDoc.InnerTex t & "-------]")
End If
End If

'Catch ex As System.Net.WebE xception
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>proces s</title></head>
<body>
<form id="Form1" method="post" runat="server">
<script LANGUAGE="VBSCR IPT" runat="server" >

Response.Buffer =True
Response.Conten tType = "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 9377


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(myR esponseStream) 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(sende r as object, e as Eventargs)

Dim wRequest As System.Net.Http WebRequest
Dim wResponse As System.Net.Http WebResponse
Dim StreamHandler As System.IO.Strea mReader
Dim xmlDoc As New System.Xml.XmlD ocument

Try
Dim URL As String = "http://localhost/aspnet/process.asp"
wRequest = System.Net.WebR equest.Create(U RL)
wRequest.Header s.Add("Man", "GET " & URL)
wResponse = CType(wRequest. GetResponse,
System.Net.WebR esponse)
If wRequest.HaveRe sponse Then
if wResponse.Statu sCode = Net.HttpStatusC ode.OK Then
streamHandler = New
System.IO.Strea mReader(wRespon se.GetResponseS tream())
xmlDoc.LoadXml( StreamHandler.R eadToEnd)
MsgBox("[--------" & xmlDoc.InnerTex t & "-------]")
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>proces s</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(my ResponseStream) 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*******@yaho o.de> wrote in message news:<41******* *@olaf.komtel.n et>...
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(myR esponseStream) 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(sende r as object, e as Eventargs)

Dim wRequest As System.Net.Http WebRequest
Dim wResponse As System.Net.Http WebResponse
Dim StreamHandler As System.IO.Strea mReader
Dim xmlDoc As New System.Xml.XmlD ocument

Try
Dim URL As String = "http://localhost/aspnet/process.asp"
wRequest = System.Net.WebR equest.Create(U RL)
wRequest.Header s.Add("Man", "GET " & URL)
wResponse = CType(wRequest. GetResponse,
System.Net.WebR esponse)
If wRequest.HaveRe sponse Then
if wResponse.Statu sCode = Net.HttpStatusC ode.OK Then
streamHandler = New
System.IO.Strea mReader(wRespon se.GetResponseS tream())
xmlDoc.LoadXml( StreamHandler.R eadToEnd)
MsgBox("[--------" & xmlDoc.InnerTex t & "-------]")
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>proces s</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.time out 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
2636
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 bandwidth, but if I'm not mistaken, these are HTTP 1.1 headers, so I can't reasonably expect a web server to respond correctly to my requests. (In my...
8
10629
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 Request" was the original error msg now that I reinstalled iislockdown and urscan I get "The parameter is incorrect." If I use the get method with this...
5
6848
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 Response.AppendHeader("MYKEY", "myValue") and do a redirect to SecondPage.aspx
7
6861
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 only problem with doing this is that a header (name of the page and Page x of x) and footer (actual page filename the date) are included. I am...
3
14522
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 sequence: ******************************************** CLIENT:: Request ********************************************
1
3445
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 connection, between others... Since that I cannot use any higher level procedures such as WebClient, HTTPWebRequest and Response. The problem is...
3
2136
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 implemented it via fsockopen, like this: <? $url = $_REQUEST; // take the param as $uri //... more ...
3
3150
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 if user hits Cancel button'; exit; } else {
4
5792
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:
0
7851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8072
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7605
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7924
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6195
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5177
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2055
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 we have to send another system
1
1171
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
884
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.