views:

748

answers:

2

Hello! I'm having a problem sending XML through Microsoft.XMLHTTP object in ASP (not .NET). I have CDATA elements inside some of the XML nodes and i get this error while trying to send.

msxml3.dll error '80070005' Access is denied.

First of all, this only comes up with CDATA. If i remove it, all sends allright. I did a little googling and found out that i need to create an MSXML2.ServerXMLHTTP object BUT hosting server seems not to support this and i get invalid request error...

Here's ASP sending code:

Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")   
xmlhttp.Open "POST", m_sURL, False
xmlhttp.Send m_sXMLString

So, is there anyway to send XML with CDATA using Microsoft.XMLHTTP? Thanks!

+1  A: 

First of all you shouldn't be using the Microsoft.XMLHTTP in ASP. It's not thread safe and will cause your app to fail mysteriously and other customer sites if you're on a shared platform.

You should be using MSXML2.ServerXMLHTTP instead.

You should also set the content type header:

Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.setRequestHeader "Content-Type", "text/xml" 
xmlhttp.Open "POST", m_sURL, False
xmlhttp.Send m_sXMLString

And one final thing, don't use a name value pair for the content you're posting to the remote server. Just send the XML itself.

Please can you post the error you're getting, remember to turn off friendly HTTP error messages in your browser (if IE Tools -> Options -> Advanced -> Show friendly HTTP error messages [uncheck])

Kev

Kev
+1  A: 

Thanks for answering. Which error exactly do you need?

If using Microsoft.XMLHTTP, then i get

msxml3.dll error '80070005'
Access is denied

on this line:

xmlhttp.Send m_sXMLString    ' XML contains CDATA

If i use MSXML2.ServerXMLHTTP, then i get internal server error (500) here:

Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")

Oh, and i do have the header. I just didn't post it here.

I would check with your hoster to see if they've got the MSXML libraries installed and configured properly.
Kev
Yah, that's probably what i'll do. The problem is thet if they don't have them, i need to find a way around (can't change hosting).