|
Classic ASP XML Using ASP 3 and XML. See also the XML category for more XML discussions not relating to ASP. NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
July 26th, 2003, 11:52 PM
|
Registered User
|
|
Join Date: Jul 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Using XMLHTTP to POST form data
Hello,
I can't find any reference to this problem I'm having. I'm using the following lines to POST form data to the next page:
Response.Buffer = true;
xml = Server.CreateObject("Microsoft.XMLHTTP");
xml.Open("POST", "http://localhost/something.asp", false);
xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xml.Send("name=Joe Smith");
Response.Write(xml.responseText);
Joe Smith is sent as two words, but when it gets to the next page and I do a Response.write, it is output as JoeSmith... the space is removed.
How do I keep the space?
Thank you kindly!
|
July 28th, 2003, 04:30 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Have you tried replacing the space with "%20", or with "+"?
BTW can't you just use Server.Transfer, or pass it in a query string to the next page?
|
July 28th, 2003, 02:07 PM
|
Registered User
|
|
Join Date: Jul 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
My next step will be to replace the spaces with %20, but I don't want to mess around with the passed parameters unless I have to. Passing as a query string isn't an option as I'd like to keep the parameters hidden from the user, but I'd also like to accomplish this server-side rather than using JavaScript.
I'm not familiar with Server.Transfer; I'll look that up, thanks.
|
July 30th, 2003, 03:02 AM
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
why don't you just use FORM with POST method?
A big advantage of XMLHTTP is communicate with server without going anywhere.
if you really want to do so, try to send an XML string instead:
xml.send("<root name='Joe Smith'/>");
at the server, read it like:
xml.load(Request)
strName = xml.documentElement.getAttribute("name")
|
September 11th, 2003, 03:53 PM
|
Registered User
|
|
Join Date: Sep 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Alright, I'm having a problem similar to the first one in this topic. I basically am Using a VB application to post XML to an asp page. I've created the code that sends the post ... and so far I think it's working fine. It is as follows:
Dim oHttp As New XMLHTTP
oHttp.Open "POST", "http://www.myurl.com/blah.asp", False
oHttp.setRequestHeader "Content-Type", "text/xml"
oHttp.send "<xml text>contents of the file</xml>"
Now that is executing and I'm getting back the responseText just fine, the only problem is I can't figure out how to extract the xml in the asp page. I can access all the header information via Request.ServerVariables ... and if I check Request.ServerVariables("CONTENT_LENGTH") it tells me there is 1200+ characters of inromation in the post, I just can't figure out how to access it?
How do I pull out my xml data so that I can save it as an xml file on the server? Do i need to load it into a DOM object? can I just reference it directly?
Help...
|
September 14th, 2003, 12:32 PM
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Kells
> oHttp.send "<xml text>contents of the file</xml>"
your xml is not well-formed and could not be loaded on the server: in <xml text>, if text is attribute, you need a value for it, ie. <xml text='some value'>
'you were right, on the server, you need to load it into an XML object before you can access it
Set xmlReq = Server.CreateObject("Msxml2.DOMDocument.4.0")
Call xmlReq.load(Request)
'optionally, and you can save it
Call xmlReq.save("C:\MyDocument.xml")
Regards
|
October 14th, 2003, 11:33 AM
|
Registered User
|
|
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Is very simple: in the send string, use the "Escape" function to resolve this problem
Response.Buffer = true;
xml = Server.CreateObject("Microsoft.XMLHTTP");
xml.Open("POST", "http://localhost/something.asp", false);
xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xml.Send Escape("name=Joe Smith");
Response.Write(xml.responseText);
|
October 27th, 2003, 01:06 PM
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry if I've missed the point somwhere.....
How would you save/use the xml if it is not well formed and you cannot therefore load it into into an XML Object on the server side?
Thanks
|
January 6th, 2004, 05:44 AM
|
Registered User
|
|
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I came across this post in an effort to find out why something I was doing was not working. Similarly I was creating a "Microsoft.XMLHTTP" server object and was not having any luck at all. I came across a Microsoft Article (lost the link--sorry) which showed a different object. The line copied from their code replacing the equivalent in the below example, as well as my own code, allowed it to properly execute. The object is listed below.
Server.CreateObject("MSXML2.ServerXMLHTTP")
Hope that helps someone else.
|
|
|