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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP & XML

Status
Not open for further replies.

ikh

Programmer
Apr 17, 2001
24
0
0
CA
Hi,
I need to write ASP code (Server side) that will accept XML message sent using HTTP POST method. I am new to ASP and XML so some simple examples would be greatly appreciated.
Thank you.
 
Google on "xmlhttp". Read around in what you find there. Construct some simple test pages based on the wealth of examples.

Dave Gee
 
try this:

Code:
<%
  Dim xml

  Response.Buffer = True
  Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "POST", "[URL unfurl="true"]http://www.tektips.com/threadhome.cfm"[/URL] , False 
  xml.Send 
  Response.Write xml.responseText
  Set xml = Nothing
%>


hth

simon
 
I think the keyword was "accept".

In this case the XML is being sent to your page and you want to capture it as it comes in and then drop it either into a file or an MSXML object.
You should be able to capture the XML into an XML object simply by doing a load function on the Request, like so:
Code:
<%
Dim xmlDoc
Set xmlDoc = Server.CreateObject("Msxml.DOMDocument")
xmlDoc.load(Request)
%>
At that point you couldthen manipulate the XML, print it, save it, etc.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
I created receive.asp file with Tarwn's code
<%
Dim xmlDoc
Set xmlDoc = Server.CreateObject("Msxml.DOMDocument")
xmlDoc.load(Request)
%>

I also created following program to send XML:

oHTTP = CREATEOBJECT('Microsoft.XMLHTTP')
oHTTP.Open("POST","xmltext = "<Start>Hello</Start>"
xmldoc= CreateObject("Microsoft.XMLDOM")
xmldoc.loadXML(xmltext)
oHTTP.Send(xmldoc)
lcRawResponse = oHTTP.ResponseText

After running this code I get "501 Not Supported" message
in lcRawResponse variable.
Any idea what is wrong?
Thank you.
 
Thats the 501 error you would be seeing when it was generated by the first page. If it couldn't find it at all you would get a 400 error in the response text.
Looks like you might be getting an error with the first script, is tere any additional debugging info being sent in the ResponseText?

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
No, 501 error is the only thing that I've got.

Thanks.
 
I converted your sending program to ASP (not sure what it is in now, doesn't look familiar - similar to VBScript but I haven't seen .F. before) and ran it. The problem I was having was that the ASP script did not have write access to the folder it was in when I added in a save line to sabe the incoming XML. By Response.Writing in the converted sending program I was able to see the full error message that was being returned (which is how I knew it was a permission issue on my save line).

Here is the ASP version of the sending prog:
Code:
<%
Set oHTTP = Server.CreateObject("Microsoft.XMLHTTP")
oHTTP.Open "POST","[URL unfurl="true"]http://localhost/tt/sample2.asp",False[/URL]
xmltext = "<Start>Hello</Start>"

Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
xmldoc.loadXML(xmltext)
oHTTP.Send(xmldoc)
lcRawResponse = oHTTP.ResponseText

Response.Write "<h1>Result:</h1>" & lcRawResponse
%>

And then the other sample file (sample2.asp) that I have running is almost exactly like yours except I tried using Microsoft.XMLDOM as the object:
Code:
<%
Dim xmlDoc
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.load(Request)

xmlDoc.Save("SampleXMLOutput.xml")
%>

The other wierd thing about your program is that your using single quotes in one of your createObject calls, which is generally a comment character in all of the VB-like languages I have used. Dunno if this could be affecting it.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
It looks weird because I am running client part from VFP not VB. Are you suggesting that I should check my permissions on IIS where receive.asp is located?
Thanks.
 
I would suggest trying it from the ASP sender I wrote (with changed addres of course) because that ought to give you the entire error message, then if it is a permissions issue or omething like that we will be able to see the full error message that is being created.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top