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 September 11th, 2003, 04:58 PM
Registered User
 
Join Date: Sep 2003
Location: Edmonton, , Canada.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Posting XML to an ASP page using XMLHTTP

Im basically 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:
VBCode:
Quote:
quote: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?

Okay, this is the code i'm trying to use to extract the XML from the post and save it as an xml file:
Quote:
quote:dim xmldoc
set xmldoc = Server.CreateObject("Msxml2.DOMDocument")
xmldoc.async = false
xmldoc.resolveExternals = false
xmldoc.load(Request)
xmldoc.save(Server.MapPath("sample.xml"))
I don't know if it matters but my text xml is as follows:
Quote:
quote:<AuthorsList>
    <Author au_id="0001" au_name="Kelly"/>
    <Author au_id="0002" au_name="Derek"/>
    <Author au_id="0003" au_name="Don"/>
<AuthorsList>
My result? well let's just say I have a very empty sample.xml file on the server that I want to be filled with the xml I'm sending!!!

Help...
Reply With Quote
  #2 (permalink)  
Old September 12th, 2003, 10:11 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,413
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I think the problem you are having is that you are not specifying what fields the posted data belongs to. I haven't worked with this object, but it seems there is something missing.

I just found something that might be useful...
http://www.eggheadcafe.com/articles/20010510.asp

Maybe this will work...

oHttp.send "xml=" & Server.URLEncode("<xml text>contents of the file</xml>")

This will specify your xml "stream" as the form field "xml"
Then on your receiving asp page you just need to do this:

xmldoc.load(Request("xml"))

Also, if you wanted to add additional fields to your post data, you need to separate with a "&" just like you do in a regular URL.

HTH,
Peter
Reply With Quote
  #3 (permalink)  
Old September 13th, 2003, 03:31 AM
Authorized User
 
Join Date: Sep 2003
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi planoie.
   xmldoc.load(Request("xml")) does not work.
Also cannot use Server.URLEncode in vb.net. Any equivalent of this ?

If you don't mind can I add you MSN address in my buddy list ?

Thanks for all your help.
Reply With Quote
  #4 (permalink)  
Old September 15th, 2003, 10:23 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,413
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Sorry, I missed that you are generating this request from VB. Try this...
System.Web.HttpUtility.UrlEncode()
When you are in a web application, this method is immediately visible because of all the default references and imports.

I'm not sure what to tell you about the XMLdoc.load problem. You could be more explicit and write xmldoc.load(Request.Form("xml"))

The other thing you could do is write a simple loop that just goes thru all the form elements to make sure everything's getting posted correctly:

Dim sKey
For Each sKey In Request.Form
    Response.Write(sKey & ":" & Request.Form(sKey) & "<br>")
Next

Peter
Reply With Quote
  #5 (permalink)  
Old September 15th, 2003, 04:14 PM
Registered User
 
Join Date: Sep 2003
Location: Edmonton, , Canada.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Unfortunately you can't use Server.URLEncode or System.Web.HttpUtility.UrlEncode() in VB 6 ;) not using VB.NET here .. yet.

Any suggestions how to encode the HTML in VB6?

Reply With Quote
  #6 (permalink)  
Old April 24th, 2014, 06:54 AM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2014
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Planoi,

I am doing the above process suggested by you in my classic asp code. But i am not getting correct results. Could you please help me out here. My code is

Send Request.asp
Dim xmlString, httpRequest, postResponse,msXMLDocu,NewXmlDoc

xmlString = "<?xml version=""1.0"" encoding=""UTF-8""?><School><Class>10</Class></School>"

Set msXMLDocu = Server.CreateObject("Msxml2.DOMDocument.6.0")
'msXMLDocu.ValidateOnParse = True
msXMLDocu.async = False
msXMLDocu.LoadXML(xmlString)

Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
httpRequest.Open "POST", "http://localhost/TestVBScript/RecieveRequest.asp", True
httpRequest.SetRequestHeader "Content-Type", "text/xml"
httpRequest.Send Server.URLEncode(msXMLDocu.xml)

If Err.Number <> 0 Then
Response.Write("Your web site does not appear to be up right now. Please try again later.")
Err.Clear
Else
Response.write("data successfully posted<br />")
End if

Now i want to receive the request on ReceiveRequest.asp page and i have written below code there
Dim xmlDoc
set xmlDoc=Server.CreateObject("MSXML2.DOMDocument")
xmlDoc.async="True"
xmlDoc.load(Request)

Also i am using the worker process in visual studio to debug the code. When i do post from one page to other, is there any way my debugger will shift to that location.

Any help will be appreciated, Thanks in advance.

Salil Gupta
+91-9718063565

Last edited by salilg; April 24th, 2014 at 07:04 AM.
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
Problem Posting XML data via XMLHTTP steelrose XML 1 November 15th, 2007 05:19 PM
PROBLEMS! Posting Form Fields with XMLHTTP kevorkian Classic ASP XML 2 December 7th, 2006 03:43 PM
Posting String Array From one page to another page Samatha ASP.NET 1.0 and 1.1 Professional 1 December 6th, 2006 03:54 AM
post xml using xmlhttp in vb.net datakix VB.NET 3 December 21st, 2004 01:31 PM
XML Post using microsoft.XMLHTTP csmajor231 XML 0 April 5th, 2004 04:06 PM



All times are GMT -4. The time now is 05:37 PM.


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