CIT_DEV
asked on
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.Fr eethreaded XMLDOM")
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.errorCod e & "<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.Serve rXMLHTTP")
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.GetAllResponseHead ers & "<br>"
'------------------------- ---------- ---------- ---------- ---------- ------
' Get XML response from AT&T Extranet
'------------------------- ---------- ---------- ---------- ---------- ------
Set xmlDoc2 = CreateObject("MSXML2.DOMDo cument")
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("Micro soft.FreeT hreadedXML DOM")
objDOM.loadXML Response_Doc
Set objNode = objDOM.documentElement.sel ectSingleN ode("Respo nse/PunchO utSetupRes ponse/Star tPage/URL" )
If Not ObjNode Is Nothing Then
strURL = objNode.text
Response.Write "<br>The URL " & strURL & "<br>"
Response.Redirect strURL
End If
End if
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.Fr
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.errorCod
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.Serve
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 "-------------------------
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
'-------------------------
' Get XML response from AT&T Extranet
'-------------------------
Set xmlDoc2 = CreateObject("MSXML2.DOMDo
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 "-------------------------
'-------------------------
' Parse the XML response from Intercall Extranet and retrieve the URL
'-------------------------
Set objDOM = Server.CreateObject("Micro
objDOM.loadXML Response_Doc
Set objNode = objDOM.documentElement.sel
If Not ObjNode Is Nothing Then
strURL = objNode.text
Response.Write "<br>The URL " & strURL & "<br>"
Response.Redirect strURL
End If
End if
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You have the progid incorrect in a number of places, actually! ;^)
Set objDOM = Server.CreateObject("Micro soft.FreeT hreadedXML DOM")
should be:
Set objDOM = Server.CreateObject("Msxml 2.Freethre adedDomDoc ument")
For a bit of clarification, this: "Microsoft.FreeThreadedXML DOM" 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
Set objDOM = Server.CreateObject("Micro
should be:
Set objDOM = Server.CreateObject("Msxml
For a bit of clarification, this: "Microsoft.FreeThreadedXML
Regards,
Mike Sharp
ASKER
When i changed to the following line of code.
StrURL = "http://att.ws.com/UserXML.asp"
Set xmlObj = CreateObject("Msxml2.Freet hreadedDom Document")
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.
StrURL = "http://att.ws.com/UserXML.asp"
Set xmlObj = CreateObject("Msxml2.Freet
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.
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
Can you expose the source XML to the internet for me to look at?
Regards,
Mike Sharp
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
Regards,
Mike Sharp
ASKER
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:3 9:09-08:00 ">
<Header>
<From>
<Credential domain="AribaNetworkUserId ">
<Identity>DI001</Identity>
</Credential>
</From>
<To>
<Credential domain="DUNS">
<Identity>176899-T</Identi ty>
</Credential>
</To>
<Sender>
<Credential domain="AribaNetworkUserId ">
<Identity>0001</Identity>
<SharedSecret>BJ1^msnD</Sh aredSecret >
</Credential>
<UserAgent>Ariba ORMS 5.1P4 </UserAgent>
</Sender>
</Header>
<Request>
<PunchOutSetupRequest operation="create">
<BuyerCookie>34234234ADFSD F234234</B uyerCookie >
<Extrinsic name="TSANumber"/>
<Extrinsic name="RequestorFirstname"> Smith</Ext rinsic>
<Extrinsic name="RequestorMiddlename" >Praker</E xtrinsic>
<Extrinsic name="RequestorLastname">S wensons</E xtrinsic>
<Extrinsic name="Email">ces5@attws.co m</Extrins ic>
<Extrinsic name="RequestorLocation">M .20.2B</Ex trinsic>
<Extrinsic name="RequestorEmployeeID" >00725679G </Extrinsi c>
<Extrinsic name="Firstname">Smith</Ex trinsic>
<Extrinsic name="Middlename">Praker</ Extrinsic>
<Extrinsic name="Lastname">Swensons</ Extrinsic>
<Extrinsic name="ClientEmail">ces7871 5@attws.co m</Extrins ic>
<Extrinsic name="Location">M.20.2B</E xtrinsic>
<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>
<?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:3
<Header>
<From>
<Credential domain="AribaNetworkUserId
<Identity>DI001</Identity>
</Credential>
</From>
<To>
<Credential domain="DUNS">
<Identity>176899-T</Identi
</Credential>
</To>
<Sender>
<Credential domain="AribaNetworkUserId
<Identity>0001</Identity>
<SharedSecret>BJ1^msnD</Sh
</Credential>
<UserAgent>Ariba ORMS 5.1P4 </UserAgent>
</Sender>
</Header>
<Request>
<PunchOutSetupRequest operation="create">
<BuyerCookie>34234234ADFSD
<Extrinsic name="TSANumber"/>
<Extrinsic name="RequestorFirstname">
<Extrinsic name="RequestorMiddlename"
<Extrinsic name="RequestorLastname">S
<Extrinsic name="Email">ces5@attws.co
<Extrinsic name="RequestorLocation">M
<Extrinsic name="RequestorEmployeeID"
<Extrinsic name="Firstname">Smith</Ex
<Extrinsic name="Middlename">Praker</
<Extrinsic name="Lastname">Swensons</
<Extrinsic name="ClientEmail">ces7871
<Extrinsic name="Location">M.20.2B</E
<Extrinsic name="EmployeeID">007679G<
<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>
ASKER
There is no white space before the XML file.
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
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
ASKER
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.rea son): No data is available for the requested resource.
Error File Position(ParseError.filepo s): 0
Error Line(ParseError.line): 0
Error Line Position(ParseError.linepo s): 0
Hre is the errors i get.
No data is available for the requested resource. Error Code: -2146697209
Error Code (ParseError): -2146697209
Error Description(ParseError.rea
Error File Position(ParseError.filepo
Error Line(ParseError.line): 0
Error Line Position(ParseError.linepo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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 .DOMDOCUME NT")
objDOM.loadxml Response_Doc
Response.Write "<b>Error Description(xmlObj.ParseEr ror.reason ):</b> " & xmlObj.ParseError.reason & "<br>"
Set objNode = objDOM.documentElement.sel ectSingleN ode("Respo nse/PunchO utSetupRes ponse/Star tPage/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="OWNV1GD3ZJMPLB4 R0EZSFFA-1 0929492496 58" timestamp="2004-08-19T14:0 0:49PDT" xml:lang="en-US"><Response ><Status code="200" text="OK"/><PunchOutSetupR esponse><S tartPage>< URL><![CDA TA[https://business.attwireless.com/platform/cXML/PunchOutStartupDispatch;dsessionid=OWNV1GD3ZJ4R0EZSFFA?&operation=create]]></UR L></StartP age></Punc hOutSetupR esponse></ Response>< /cXML>
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
objDOM.loadxml Response_Doc
Response.Write "<b>Error Description(xmlObj.ParseEr
Set objNode = objDOM.documentElement.sel
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="OWNV1GD3ZJMPLB4
ASKER
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
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
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("Select ionLanguag e", "XPath");
Regards,
Mike Sharp
objDOM.setProperty("Select
Regards,
Mike Sharp
Set xmlObj = CreateObject("Msxml2.Freet
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