Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Below is my asp pages trying for xml request/response

Request.asp (from client)

HTML
<%
    pXML = "<XmlRequest><FileNo>123</FileNo></XmlRequest>"
    Set http = CreateObject("MSXML2.ServerXMLHTTP")
    http.open "GET", "http://test.com/response.asp?xml_request=" & pXML, 0
    http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    http.send ""
    http_response = http.responseText
%>


Response.asp (in the server)

HTML
<%
xml_request = Request.QueryString("xml_request")

Set xd= Server.CreateObject("Msxml2.DOMDocument")
xd.async = False
xd.loadXML(Xml_Request)

FileNo = xd.getElementsByTagName("XmlRequest").item(0).getElementsByTagName("FileNo").item(0).text
''' here is the problem
%>


Response file is in this server path `Server.MapPath("123.xml")` (this is a large file)

1.How i send response file to the "Request.asp" from "Response.asp"

2.i need a solution with out response.write

3.How send response xml file to the client ?
Posted
Updated 22-Feb-12 6:00am
v2

1 solution

Since you can't use Response.Write (why though?) - why not save your file to a public location on the server (or a secured one) then send back the URL to that file (and any necessary security information) through hidden fields in your form (I assume you have one in your requested page somewhere?) and then have the requesting code read the form information and request the XML file separately. Finally, you can have an extra page it calls that tells your server to delete the file. (Though why your requesting code couldn't just load the wanted XML file in the first place since you appear to be trying to get a file number and get the correct file I have no idea... :S )

Hope this helps,
Ed
 
Share this answer
 
Comments
amtechq8 22-Feb-12 15:48pm    
1. if i use response.write, it takes more time to write xml file.
2. ok i can save file to the public location then how i can send back url?
Ed Nutting 22-Feb-12 16:05pm    
Wrong - saving your file, then getting another request (for which the response will be done with equivalent of Respon.seWrite) means that actually you've wasted a lot of server space, time and bandwidth - you have not solved your problem. The best solution would be for you to just request the original file in the first place, though there are situations where this isn't possible. In which case you should just set Response.ContentType to text/xml and then write back the XML file. However, if you insist upon not doing this, have an input tag inside your requested page's form - call it something like "XMLFileURL" and then set its value to the url of your temporary XML file.
amtechq8 22-Feb-12 16:29pm    
i not understand well.. can u arrange some sample code plz...
amtechq8 22-Feb-12 16:38pm    
i try like below in the response.asp
FileNo = xd.getElementsByTagName("XmlRequest").item(0).getElementsByTagName("FileNo").item(0).text

Dim doc
Set doc = CreateObject("Msxml2.DOMDocument.3.0")
doc.async = False
If doc.load(Server.MapPath(FileNo&".xml")) Then
Response.buffer = true
doc.Save Response

Else

response.write " handle error in 123.xml here"

End If

But it take time to load

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900