• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7999
  • Last Modified:

Issues with loading an XML document using .load method

I get the following error.

Microsoft VBScript runtime (0x800A01AD)
ActiveX component can't create object: 'MSXML4.ServerXMLHTTP'

when i open the http://att.ws.com/UserXML.asp i get a properly formatted XML document. But when i try to load the using the URL, it errors out.

***********************************************************
The Code is as follows
***********************************************************

StrURL         = "http://att.ws.com/UserXML.asp"

Set xmlObj = CreateObject("Microsoft.FreethreadedXMLDOM")
xmlObj.SetProperty "ServerHTTPRequest", False
xmlObj.async = False
xmlObj.load  StrURL

'-----------------------------------------------------------------------
' Check XML document
'-----------------------------------------------------------------------
If Not xmlObj.ParseError = 0 Then
  Response.Write "<b>Error Code:</b> " & xmlObj.ParseError & "<br>"
  Response.Write "<b>Error Code:</b> " & xmlObj.ParseError.errorCode & "<br>"
  Response.Write "<b>Error Description:</b> " & xmlObj.ParseError.reason & "<br>"
  Response.Write "<b>Error File Position:</b> " & xmlObj.ParseError.filepos & "<br>"
  Response.Write "<b>Error Line:</b> " & xmlObj.ParseError.line & "<br>"
  Response.Write "<b>Error Line Position:</b> " & xmlObj.ParseError.linepos & "<br>"
  Response.Write "<b>Error URL pointing the loaded document</b> " & xmlObj.ParseError.url & "<br>"
  Response.Write "<b>Error Source Text:</b> " & xmlObj.ParseError.srcText & "<br>"
Else
  '-----------------------------------------------------------------------
  ' Send XML request - AT&T Extranet
  '-----------------------------------------------------------------------
  VendorURL      =      "https://stg-busweb01.attwireless.com/aps/PunchOutSetupRequestDispatch"
  Set XMLhttp = CreateObject("MSXML2.ServerXMLHTTP")
  XMLhttp.Open "POST", VendorURL, False
  XMLhttp.Send "requestMessage=" & xmlObj.xml
   
  '-----------------------------------------------------------------------
  ' Get server status
  '-----------------------------------------------------------------------
  Response.Write "<textarea rows=20 cols=100  id=textarea1 name=textarea1>" & xmlObj.xml  & "</textarea>"
  Response.Write "<br>"
  Response.Write "<b><font face=arial size=2>ATT Server Status:</b><br>"
  Response.Write "-----------------------------------------<br>"
  Response.Write "<b>Status (Value must be 200): </b>" & XMLhttp.status & "<br>"
  Response.Write "<b>ReadyState (Value must be 4): </b>" & XMLhttp.ReadyState & "<br>"
  Response.Write "<b>StatusText (Value must be OK): </b>" & XMLhttp.StatusText & "<br>"
  Response.Write "<b>AllResponseHeaders:</b><br>" & XMLhttp.GetAllResponseHeaders & "<br>"
  '-----------------------------------------------------------------------
  ' Get XML response from AT&T Extranet
  '-----------------------------------------------------------------------
  Set xmlDoc2 = CreateObject("MSXML2.DOMDocument")
  xmlDoc2.setProperty "ServerHTTPRequest", True
  xmlDoc2.async = False
  xmlDoc2.LoadXML XMLhttp.ResponseXML.xml
  Response.Write "<br>"
 
  Response_Doc = xmlhttp.responseXML.xml
  Response.Write "<textarea rows=20 cols=100  id=textarea1 name=textarea1>" & Response_Doc  & "</textarea>"
 
  Response.Write "<br><br><br><b>ATT Profile Results</b><br>"
  Response.Write "-----------------------------------------<br>"
 
  '-----------------------------------------------------------------------
  ' Parse the XML response from Intercall Extranet and retrieve the URL
  '-----------------------------------------------------------------------
 
  Set objDOM = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
  objDOM.loadXML Response_Doc
  Set objNode = objDOM.documentElement.selectSingleNode("Response/PunchOutSetupResponse/StartPage/URL")
  If Not ObjNode Is Nothing Then
      strURL = objNode.text
      Response.Write "<br>The URL  " & strURL & "<br>"
      Response.Redirect strURL
  End If
 
End if  
0
CIT_DEV
Asked:
CIT_DEV
  • 8
  • 6
2 Solutions
 
rdcproCommented:
If you're loading from a URL, not a filesystem path, you need to set the ServerHTTPRequest property to true, not false:

Set xmlObj = CreateObject("Microsoft.FreethreadedXMLDOM")
xmlObj.SetProperty "ServerHTTPRequest", True
xmlObj.async = False
xmlObj.load  StrURL

Regards,
Mike Sharp
0
 
rdcproCommented:
Oh, I just noticed something else (I cut-and-pasted your code) The progid is incorrect.  Use:

Set xmlObj = CreateObject("Msxml2.FreethreadedDomDocument")
xmlObj.SetProperty "ServerHTTPRequest", True
xmlObj.async = False
xmlObj.load  StrURL


And if you get this error:

Microsoft VBScript runtime (0x800A01AD)
ActiveX component can't create object: 'MSXML4.ServerXMLHTTP'

Then the progid is incorrect here too.  It should be "MSXML2.ServerXMLHTTP"

Regards,
Mike Sharp
0
 
rdcproCommented:
You have the progid incorrect in a number of places, actually!  ;^)

  Set objDOM = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")

should be:

  Set objDOM = Server.CreateObject("Msxml2.FreethreadedDomDocument")

For a bit of clarification, this:  "Microsoft.FreeThreadedXMLDOM"  identifies the old MSXML 2 parser.  MSXML 3, SP1 or later, installs in replace mode, and re-maps the progid to the newer parser, so it will actually work with the old ProgID.  But it's still wrong, and could conceivably cause problems.  Don't use any progid that starts with "Microsoft" as this refers to the old parser.


Regards,
Mike Sharp
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
CIT_DEVAuthor Commented:
When i changed to the following line of code.

StrURL        = "http://att.ws.com/UserXML.asp"

Set xmlObj = CreateObject("Msxml2.FreethreadedDomDocument")
xmlObj.SetProperty "ServerHTTPRequest", true
xmlObj.async = False
xmlObj.load  StrURL
.....etc


I GET THE FOLLOWING ERROR

Error Code: -1072896681
Error Code: -1072896681
Error Description: Invalid xml declaration.
Error File Position: 4
Error Line: 2
Error Line Position: 3
Error URL pointing the loaded document http://att.ws.com/UserXML.asp
Error Source Text:

And WHEN I OPEN THE http://att.ws.com/UserXML.asp in the browser, i get a fully quality XML file stream.
0
 
rdcproCommented:
I'm pretty sure this is a parse error though.  I wonder if the XML produces a byte order mark (hence the error message saying file position 4) that's incorrect.  Using IE to load the XML is probably a lot more forgiving regarding character encoding and the BOM.

Can you expose the source XML to the internet for me to look at?

Regards,
Mike Sharp
0
 
rdcproCommented:
Also, be sure there is no whitespace *before* the XML Declaration in the XML.  If you have a newline before the declaration, the XML will open in IE, but it will throw a parse error if you try to use the documentObject.load() method.

Regards,
Mike Sharp
0
 
CIT_DEVAuthor Commented:
Here goes the XML file.

<?xml version="1.0" encoding="UTF-8"?>
<cXML payloadID="8/12/2004 4:03:18 P93766443@attws.com" xml:lang="en-US" timestamp="1999-03-12T18:39:09-08:00">
      <Header>
            <From>
                  <Credential domain="AribaNetworkUserId">
                        <Identity>DI001</Identity>
                  </Credential>
            </From>
            <To>
                  <Credential domain="DUNS">
                        <Identity>176899-T</Identity>
                  </Credential>
            </To>
            <Sender>
                  <Credential domain="AribaNetworkUserId">
                        <Identity>0001</Identity>
                        <SharedSecret>BJ1^msnD</SharedSecret>
                  </Credential>
                  <UserAgent>Ariba ORMS 5.1P4 </UserAgent>
            </Sender>
      </Header>
      <Request>
            <PunchOutSetupRequest operation="create">
                  <BuyerCookie>34234234ADFSDF234234</BuyerCookie>
                  <Extrinsic name="TSANumber"/>
                  <Extrinsic name="RequestorFirstname">Smith</Extrinsic>
                  <Extrinsic name="RequestorMiddlename">Praker</Extrinsic>
                  <Extrinsic name="RequestorLastname">Swensons</Extrinsic>
                  <Extrinsic name="Email">ces5@attws.com</Extrinsic>
                  <Extrinsic name="RequestorLocation">M.20.2B</Extrinsic>
                  <Extrinsic name="RequestorEmployeeID">00725679G</Extrinsic>
                  <Extrinsic name="Firstname">Smith</Extrinsic>
                  <Extrinsic name="Middlename">Praker</Extrinsic>
                  <Extrinsic name="Lastname">Swensons</Extrinsic>
                  <Extrinsic name="ClientEmail">ces78715@attws.com</Extrinsic>
                  <Extrinsic name="Location">M.20.2B</Extrinsic>
                  <Extrinsic name="EmployeeID">007679G</Extrinsic>
                  <BrowserFormPost>
                        <URL>https://att.ws.com/ReadXML.asp</URL>
                  </BrowserFormPost>
                  <ShipTo>
                        <Address>
                              <Name xml:lang="en"/>
                              <PostalAddress>
                                    <DeliverTo>Smith Swensons</DeliverTo>
                              </PostalAddress>
                        </Address>
                  </ShipTo>
            </PunchOutSetupRequest>
      </Request>
</cXML>
0
 
CIT_DEVAuthor Commented:
There is no white space before the XML file.
0
 
rdcproCommented:
Actually, I was hoping to access it over HTTP, so I could look at headers and things.  It almost has to be either a BOM is present, or there is some character before the <?xml in the declaration.

Can you look at the parseError object?  what message does it produce?

set myErr = xmlDoc.parseError
If myErr.errorCode <> 0 Then
   Response.Write myErr.reason
Else

Regards,
Mike Sharp
0
 
CIT_DEVAuthor Commented:
Hi Mike

Hre is the errors i get.

No data is available for the requested resource. Error Code: -2146697209

Error Code (ParseError): -2146697209
Error Description(ParseError.reason): No data is available for the requested resource.
Error File Position(ParseError.filepos): 0
Error Line(ParseError.line): 0
Error Line Position(ParseError.linepos): 0

0
 
rdcproCommented:
Well, this is usally because you're loading a URL, and not a filesystem path.  The old parser did not support the secondary properties, especially the one you need:

xmlObj.SetProperty "ServerHTTPRequest", False

You need to use MSXML 3 (or 4) for this.  So don't use:

Set xmlObj = CreateObject("Microsoft.FreethreadedXMLDOM")
xmlObj.SetProperty "ServerHTTPRequest", False

use (for MSXML 3):

Set xmlObj = CreateObject("Msxml2.FreeThreadedDomDocument")
xmlObj.SetProperty "ServerHTTPRequest", False

or use (for MSXML 4):

Set xmlObj = CreateObject("Msxml2.FreeThreadedDomDocument.4.0")
xmlObj.SetProperty "ServerHTTPRequest", False

If you still have the problem, it's possible the registry is messed up, and mapping the progIDs to the wrong parser.  I have a page that explains how to unregister, then reregister the parser, which I've pasted below.  You want to register MSXML 3 in replace mode.  MSXML 3, SP1 or later, should install in replace mode automatically...but I've heard of many cases where some other application screws up the registry.  

If none of this fixes your problem, post the *complete* code, as it stands now, because what's posted up above won't work.


Regards,
Mike Sharp

Make sure you've installed a good version of MSXML 3:

http://www.microsoft.com/downloads/details.aspx?FamilyID=c0f86022-2d4c-4162-8fb8-66bfc12f32b0&displaylang=en


Then if that doesn't fix it, you need to correct the registry settings.

Download xmlinst.exe from the XML Development Center:

http://www.microsoft.com/downloads/details.aspx?familyid=1e6185d7-e4e4-43b1-8056-0e5ecd15a88a&displaylang=en

To register MSXML 3.0 in Replace mode

At the command prompt, enter:
pathname\xmlinst –u
where pathname is the folder where xmlinst.exe is installed. This command uninstalls any registry entries for MSXML.

From the command prompt, enter:
regsvr32 msxml3.dll
This registers MSXML 3.0.

From the command prompt, enter:
pathname\xmlinst
This installs the latest version of MSXML in Replace mode.

To return to earlier versions of MSXML (side by side mode--not recommended)

In some cases, you may want to return to side-by-side mode and earlier versions of MSXML.

At the command prompt, enter:
pathname\xmlinst –u
This command uninstalls any registry entries for MSXML.

Register the versions of MSXML you wish to run.
Note   Be sure to register the versions in order. For example, to register msxml.dll, msxml2.dll, and msxml3.dll, first enter:
regsvr32 msxml.dll
and then press ENTER. Next, enter:
regsvr32 msxml2.dll
and then press ENTER. Finally, enter:
regsvr32 msxml3.dll
and then press ENTER.
The following table lists the commands you can run with xmlinst.exe.


Command Behavior
"xmlinst" Replace mode with Msxml3.dll as the new dll path.
"xmlinst pathname" Take a path as a parameter such that msxml3.dll will take over for all the registry entries created by Msxml.dll.
"xmlinst -u msmxl" Delete all entries from the registry that were created by Msxml.dll.
"xmlinst -u msxml3" Delete all entries from the registry that were created by Msxml3.dll.
"xmlinst -u" Delete all entries from the registry that were created by any version of MSXML.
"xmlinst -?"  Print usage message.
0
 
CIT_DEVAuthor Commented:
Mike That description as very informative. You deserve more than 500 point for the explaination you have provided. Points on the way..


I knocked most of the issues but i am having issues with my parsing an XML document.

I beileve it has sometime to do with our servers. It woks fine on server without any fiewall restriction but fails on the other server which has restictions.

On careful analysis i found that the error was because the DTD could not be validated. I get tge following error.

Error processing resource 'http://xml.cXML.org/schemas/cXML/1.2.008/cXML.dtd'.
Can we disable the DTD Validation while loading an xml file.

The following is the line of codes..

||||||||||||||||||||||||||||||||||||||||
Response_Doc holds the XML file content . I have included a copy of the xml file.

||||||||||||||||||||||||||||||||||||||||

      Set objDOM = Server.CreateObject("MSXML.DOMDOCUMENT")
      objDOM.loadxml Response_Doc
      Response.Write "<b>Error Description(xmlObj.ParseError.reason ):</b> " & xmlObj.ParseError.reason & "<br>"

      Set objNode = objDOM.documentElement.selectSingleNode("Response/PunchOutSetupResponse/StartPage/URL")
      If Not ObjNode Is Nothing Then
            strURL = objNode.text
            Response.Write "<br>The URL  " & strURL & "<br>"
      End If


||||||||||||||||||||||||||||||||||||||||
XML FILE THAT NEEDS TO BE PARSED
||||||||||||||||||||||||||||||||||||||||

<?xml version="1.0"?>
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.008/cXML.dtd">
<cXML payloadID="OWNV1GD3ZJMPLB4R0EZSFFA-1092949249658" timestamp="2004-08-19T14:00:49PDT" xml:lang="en-US"><Response><Status code="200" text="OK"/><PunchOutSetupResponse><StartPage><URL><![CDATA[https://business.attwireless.com/platform/cXML/PunchOutStartupDispatch;dsessionid=OWNV1GD3ZJ4R0EZSFFA?&operation=create]]></URL></StartPage></PunchOutSetupResponse></Response></cXML>


0
 
CIT_DEVAuthor Commented:
Mike.

I checked the MSDN and found the answer. I would like to share with others on this community.

By using properites ValidateOnparse and resolveexternals i fixed my code.

objDOM.validateOnParse = false
objDOM.resolveExternals = false
0
 
rdcproCommented:
In fact, I routinely set those properties whether I need to or not.  In fact, I also routinely set the SelectionLanguage secondary property as well, because I might end up using an XPath expression that isn't backwards compatible with the old MSXML 2 parser, and I hate surprises.... (jscript):

objDOM.setProperty("SelectionLanguage", "XPath");

Regards,
Mike Sharp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now