Hi all,
I had a program and it always works fine and suddenly it gives me the
following message when a pass a xml file to our server program:
error code: -1072896680 reason: XML document must have a top level element.
line #: 0
I don't know if it is my xml file or it is something else?
Here is my client side program:
<%@ Language=vbScri pt%>
<%
Set xmlDom=CreateOb ject("Microsoft .XMLDOM")
XMLDom.async =False
xmlDom.load Server.MapPath( "05272008ACTest .xml")
DataToSend = xmlDom.xml
dim xmlhttp
set xmlhttp = server.Createob ject("MSXML2.Se rverXMLHTTP")
xmlhttp.Open "POST","htt ps://www.mydomain.co m/ac/xt_ac_B2B.asp", false
xmlhttp.setRequ estHeader "Content-Type", "applicatio n/x-www-form-urlencoded"
xmlhttp.send DataToSend
if(Err <0) then
Response.Write( "An error occured when retrieving data from an external
source.<br />")
Response.Write( Err.Description )
Response.End
end if
On error goto 0
'if request is not Ok then display detailed message about the request
problem
if(xmlHttp.stat us <200) then
Response.Write( "The remote server returned an invalid statuscode: #8221;"
& _
xmlHttp.status & " " & xmlHttp.statusT ext) & "<br>"
Response.Write( "response text from remote server" & _
" " & xmlHttp.respons eText)
Response.End
end if
if xmlHttp.respons eXML is nothing then
Response.Write( "The remote server didn’t return xml content.")
Response.End
end if
Response.Conten tType = "text/xml"
Response.Write xmlhttp.respons exml.xml
Set xmlhttp = nothing
%>
and 05272008ACTest. xml file is like this:
- <enrollment orderID="200808 251114527143" PONumber="50000 "
marketingCode=" E" productName="ad ventureCenter">
<test>Y</test>
<residency>US </residency>
- <coverageOption >
<partI totalPartIPayme nt="12.55">Y</partI>
<partII totalPartIPayme nt="">N</partII>
</coverageOption>
<tripName>Europ ean Tour</tripName>
<enrollmentFee> 5.00</enrollmentFee>
<totalPayment>7 65.00</totalPayment>
<tripDates departureDate=" 5/14/2007" returnDate="5/17/2007" tripDays="4" />
<numofParticipa nt>3</numofParticipan t>
- <participants >
<participant firstName="Cind y" mInit="b" lastName="Rose"
birthdate="4/26/1955" tripCost="2500" partIPremium="1 87.50"
partIIPremium=" 25.00" />
<participant firstName="Kath y" mInit="c" lastName="Barlo w"
birthdate="6/28/1944" tripCost="2500" partIPremium="2 62.50"
partIIPremium=" 35.00" />
<participant firstName="Matt hrew" mInit="d" lastName="Kamin ski"
birthdate="4/27/1933" tripCost="2500" partIPremium="3 00.00"
partIIPremium=" 45.00" />
</participants>
<mailingInfo name="Betty Sun" address="4406 Larwin ct." city="Concord"
state="CA" province="" zip="12345" country="United States" />
<email>sunshine @yahoo.com</email>
- <phone>
<homePhone number="4057887 933">Y</homePhone>
<bizPhone>N</bizPhone>
</phone>
<enrollAgreemen t>Y</enrollAgreement >
- <payment>
<method>card</method>
<billingAddre ss name="Betty Sun" street="4406 larwin ct." city="Concord"
state="CA" province="" country="United States" />
<creditCard type="visa" number="4XXXXXX XXXXXXXX" expDate="7/2007" />
</payment>
</enrollment>
and My server program is like this:
Dim xmlDoc, InstreamXMLRoot , TestFlag
Set xmlDoc=Server.C reateObject("Mi crosoft.XMLDOM" )
xmlDoc.Load Request '--this is for xml sent via body
Response.Conten tType = "text/xml" '--for testing program
'************** *************** ******
'the server program complains here, but the funny thing
is I save the stream on the server and the file looks the same
as it is passed and it displays in the browser very well, I don't get it!!!!!
'************** *************** ******
If xmlDoc.parseErr or.errorCode <0 Then
Call UpdateXMLRespon se(orderID, "False", "XML", "error code: "
&xmlDoc.parseEr ror.errorCode & " reason: " &xmlDoc.parseEr ror.reason &" line
#: " &xmlDoc.parseEr ror.line , "")
End If
IF isNULL(xmlDoc) Then
Set InstreamXMLRoot =Nothing
Call UpdateXMLRespon se(orderID, "False", "XML", "The server didn't receive
the XML stream", "")
END IF
Set InstreamXMLRoot =xmlDoc.documen tElement
IF isNULL(Instream XMLRoot) Then
Set InstreamXMLRoot =Nothing
Call UpdateXMLRespon se(orderID, "False", "XML", "The server didn't receive
the XML stream", "")
END IF
'Save all info before any transaction
xmlDoc.Save(Ser ver.MapPath("B2 BResponse/" & hour(now) & "_" & minute(now) &
"_" & RandomNumber(10 00000) & "_" & month(now) & "_" & day(now) & "_" &
year(now) &"_B2BResponse. xml"))
--
Betty
I had a program and it always works fine and suddenly it gives me the
following message when a pass a xml file to our server program:
error code: -1072896680 reason: XML document must have a top level element.
line #: 0
I don't know if it is my xml file or it is something else?
Here is my client side program:
<%@ Language=vbScri pt%>
<%
Set xmlDom=CreateOb ject("Microsoft .XMLDOM")
XMLDom.async =False
xmlDom.load Server.MapPath( "05272008ACTest .xml")
DataToSend = xmlDom.xml
dim xmlhttp
set xmlhttp = server.Createob ject("MSXML2.Se rverXMLHTTP")
xmlhttp.Open "POST","htt ps://www.mydomain.co m/ac/xt_ac_B2B.asp", false
xmlhttp.setRequ estHeader "Content-Type", "applicatio n/x-www-form-urlencoded"
xmlhttp.send DataToSend
if(Err <0) then
Response.Write( "An error occured when retrieving data from an external
source.<br />")
Response.Write( Err.Description )
Response.End
end if
On error goto 0
'if request is not Ok then display detailed message about the request
problem
if(xmlHttp.stat us <200) then
Response.Write( "The remote server returned an invalid statuscode: #8221;"
& _
xmlHttp.status & " " & xmlHttp.statusT ext) & "<br>"
Response.Write( "response text from remote server" & _
" " & xmlHttp.respons eText)
Response.End
end if
if xmlHttp.respons eXML is nothing then
Response.Write( "The remote server didn’t return xml content.")
Response.End
end if
Response.Conten tType = "text/xml"
Response.Write xmlhttp.respons exml.xml
Set xmlhttp = nothing
%>
and 05272008ACTest. xml file is like this:
- <enrollment orderID="200808 251114527143" PONumber="50000 "
marketingCode=" E" productName="ad ventureCenter">
<test>Y</test>
<residency>US </residency>
- <coverageOption >
<partI totalPartIPayme nt="12.55">Y</partI>
<partII totalPartIPayme nt="">N</partII>
</coverageOption>
<tripName>Europ ean Tour</tripName>
<enrollmentFee> 5.00</enrollmentFee>
<totalPayment>7 65.00</totalPayment>
<tripDates departureDate=" 5/14/2007" returnDate="5/17/2007" tripDays="4" />
<numofParticipa nt>3</numofParticipan t>
- <participants >
<participant firstName="Cind y" mInit="b" lastName="Rose"
birthdate="4/26/1955" tripCost="2500" partIPremium="1 87.50"
partIIPremium=" 25.00" />
<participant firstName="Kath y" mInit="c" lastName="Barlo w"
birthdate="6/28/1944" tripCost="2500" partIPremium="2 62.50"
partIIPremium=" 35.00" />
<participant firstName="Matt hrew" mInit="d" lastName="Kamin ski"
birthdate="4/27/1933" tripCost="2500" partIPremium="3 00.00"
partIIPremium=" 45.00" />
</participants>
<mailingInfo name="Betty Sun" address="4406 Larwin ct." city="Concord"
state="CA" province="" zip="12345" country="United States" />
<email>sunshine @yahoo.com</email>
- <phone>
<homePhone number="4057887 933">Y</homePhone>
<bizPhone>N</bizPhone>
</phone>
<enrollAgreemen t>Y</enrollAgreement >
- <payment>
<method>card</method>
<billingAddre ss name="Betty Sun" street="4406 larwin ct." city="Concord"
state="CA" province="" country="United States" />
<creditCard type="visa" number="4XXXXXX XXXXXXXX" expDate="7/2007" />
</payment>
</enrollment>
and My server program is like this:
Dim xmlDoc, InstreamXMLRoot , TestFlag
Set xmlDoc=Server.C reateObject("Mi crosoft.XMLDOM" )
xmlDoc.Load Request '--this is for xml sent via body
Response.Conten tType = "text/xml" '--for testing program
'************** *************** ******
'the server program complains here, but the funny thing
is I save the stream on the server and the file looks the same
as it is passed and it displays in the browser very well, I don't get it!!!!!
'************** *************** ******
If xmlDoc.parseErr or.errorCode <0 Then
Call UpdateXMLRespon se(orderID, "False", "XML", "error code: "
&xmlDoc.parseEr ror.errorCode & " reason: " &xmlDoc.parseEr ror.reason &" line
#: " &xmlDoc.parseEr ror.line , "")
End If
IF isNULL(xmlDoc) Then
Set InstreamXMLRoot =Nothing
Call UpdateXMLRespon se(orderID, "False", "XML", "The server didn't receive
the XML stream", "")
END IF
Set InstreamXMLRoot =xmlDoc.documen tElement
IF isNULL(Instream XMLRoot) Then
Set InstreamXMLRoot =Nothing
Call UpdateXMLRespon se(orderID, "False", "XML", "The server didn't receive
the XML stream", "")
END IF
'Save all info before any transaction
xmlDoc.Save(Ser ver.MapPath("B2 BResponse/" & hour(now) & "_" & minute(now) &
"_" & RandomNumber(10 00000) & "_" & month(now) & "_" & day(now) & "_" &
year(now) &"_B2BResponse. xml"))
--
Betty
Comment