Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP XML
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 27th, 2003, 12:52 AM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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!

Reply With Quote
  #2 (permalink)  
Old July 28th, 2003, 05:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

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?
Reply With Quote
  #3 (permalink)  
Old July 28th, 2003, 03:07 PM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
  #4 (permalink)  
Old July 30th, 2003, 04:02 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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")
Reply With Quote
  #5 (permalink)  
Old September 11th, 2003, 04:53 PM
Registered User
 
Join Date: Sep 2003
Location: Edmonton, , Canada.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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...

Reply With Quote
  #6 (permalink)  
Old September 14th, 2003, 01:32 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #7 (permalink)  
Old October 14th, 2003, 12:33 PM
Registered User
 
Join Date: Oct 2003
Location: Bs As, Capital Federal, Argentina.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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);

Reply With Quote
  #8 (permalink)  
Old October 27th, 2003, 01:06 PM
dkb dkb is offline
Authorized User
 
Join Date: Oct 2003
Location: , , United Kingdom.
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Reply With Quote
  #9 (permalink)  
Old January 6th, 2004, 05:44 AM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Submitting POST data without a form takabyte Classic ASP Basics 15 April 28th, 2014 02:44 AM
post xml using xmlhttp in vb.net datakix Classic ASP XML 4 August 7th, 2009 06:31 AM
Request Post XMLHttp : Need Help Kyum BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6 5 July 5th, 2007 10:51 PM
Problem with using POST method with XMLHTTP vvr Classic ASP XML 1 December 6th, 2004 01:44 AM
XML Post using microsoft.XMLHTTP csmajor231 XML 0 April 5th, 2004 04:06 PM



All times are GMT -4. The time now is 11:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.