Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP Response

Status
Not open for further replies.

Rhys666

Programmer
May 20, 2003
1,106
I'm relatively new to dealing with internet based ASP.net, (I've been used to internal only Intranet development until recently) and am looking into building an Application that posts XML to an external site, which will parse and validate the data and return the HTTP Response Code. This side seems OK.

What will later happen is that the XML will be further amended etc. then posted to a URL within our site. But I'm having problems reading the posted XML (HTTPResponse ?) and outputting it to screen or file.

I'm really looking for opinions and help with the most practical method of reading the posted XML, saving it to a file and displaying the content on the page.


Rhys
"When one burns one's bridges, what a very nice fire it makes" -- Dylan Thomas
"As to marriage or celibacy, let a man take the course he will. He will be sure to repent" -- Socrates
 
the XML 'posted' to your website means an existing file inside your webserver. therefore a file that can be read directly from disk.

in case you don't know the location on disk of this file, just read the page returned by the url of the XML and load it into an XMLDocument which you can later on save to disk fairly easy.
 
Apparently I'm having a problem with MS XML libraries.

We're posting an XML doc to an external site which parses the doc and provides an HTTP Response Number.

We also need the XML to be re-posted from the external site to another page of ours and have the XML saved as a doc. In standard ASP we're doing this as follows...
Code:
<%
strABBXMLFile = Server.MapPath("/spider/abb/abbn/" & Day(Now) & "-" & Month(Now) & "-" & Year(Now) & "_" & Hour(Now) & Minute(Now) & "_standardAbbreviation.xml")

Set doc = Server.CreateObject("Msxml2.DOMDocument.4.0")

doc.load(Request)
doc.save(strABBXMLFile)
%>

The problem we have is with entity declaration and <!DocType > tags. With entity declarations or a DocType in the XML none of the MS XML libraries can save the XML document. If the <DocType > is removed, they xml is saved fine. Can anyone provide any further information on this issue, or if there's a work-around for it? Or do the .Net XML libraries cope with entity declarations and doctype tags, and can anyone provide any pointers to dot-netting the above?

All help much appreciated, as well as advice.

Cheers!

Rhys
"When one burns one's bridges, what a very nice fire it makes" -- Dylan Thomas
"As to marriage or celibacy, let a man take the course he will. He will be sure to repent" -- Socrates
 
try reading the source page as a string, remove the doctype (you might use regular expressions) then load the result string in a XmlDocument which you can save.
 
Cheers for your help thusfar, but I can't do what you suggest as the DocType is part of the Xml and we want to record the Xml as received, as this will be what was processed at the other end.

I believe the error is erroneous and is caused by an MS XML bug. I've got a workaround in traditional ASP via the following;
Code:
Option Explicit

Dim strABBXMLFile
strABBXMLFile = Server.MapPath("/spider/abb/abbn/" & Day(Now) & "-" & Month(Now) & "-" & Year(Now) & "_" & Hour(Now) & Minute(Now) & "_abbn.xml")

'FileIO START
Dim fso, f, strRequest
dim a,b
a = Request.TotalBytes
strRequest = BinaryToString(Request.BinaryRead(a))

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateTextFile(strABBXMLFile)

f.WriteLine(strRequest)
f.close

Set f = Nothing
Set fso = Nothing

As you can see, basically I'm retreiving the source page (the Request object) as a binary then converting the binary back to a string and using a simple File IO to save it.

In asp.net how do you retrieve the source from the Request object as a string as you suggested?

Rhys
"When one burns one's bridges, what a very nice fire it makes" -- Dylan Thomas
"As to marriage or celibacy, let a man take the course he will. He will be sure to repent" -- Socrates
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top